diff --git a/CHECKSUMS.txt b/CHECKSUMS.txt index 43b4a3a2faf6bc24ba5db3fca62b90da537ebae4..990aafd1d532f34d1a67c2e3c8a9b32016f9f1bc 100644 --- a/CHECKSUMS.txt +++ b/CHECKSUMS.txt @@ -1,23 +1,23 @@ -Cover Charge v0.3.12.196: web apps, plus the Cover Charge for Display tablet app for Android (downloads/android/, its SHA-256 is in downloads/android/SHA256.txt). No phone APKs were built for v0.1.2 to v0.3.12.196. +Cover Charge v0.3.12.197: web apps, plus the Cover Charge for Display tablet app for Android (downloads/android/, its SHA-256 is in downloads/android/SHA256.txt). No phone APKs were built for v0.1.2 to v0.3.12.197. SHA-256 of each web app's start page, service worker, manifest and logo: -6a6d0f56ffa60fbb62e3bc9fa3aac433c64e5ef2d4a0781539e50ae30775df72 owner-app/index.html -dabaca57fb03410369b80d96d3f32c0d5891bfed109713fd36f12b94feda1bd9 owner-app/sw.js +3ef1b293cad304d0bf7ba7a327ead5015cfc8ebbf2f655796fe1812099ff570a owner-app/index.html +6ca6a09077c034ac118f5034ee22830512ad38b281af4b28dc194cd1156e22bb owner-app/sw.js e305c44d11a9c25f37372f3fa4d329d4ffb04df2edee6e7b4b9ac91f3875ac67 owner-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 owner-app/brand-logo.png -995f6f7ade031aba6d2b52e68e380f34aec9c94881c30096fa467007a00768a4 staff-app/index.html -2f26ab25771825323a7ebeebd32f0229fae1754b741fa2c2c14c4a465f0e0d35 staff-app/sw.js +fe7291b4997cbc4f3b019c041ed21215436989465d7d9bda7abacceece820044 staff-app/index.html +33211516bb3d6866f27809bb683610c764d7f5b5727ab1a6ab59c4be2874aa4c staff-app/sw.js bd1d310ebf8e2a80808e100c41fb7fe1c4369d3026478f3ad8eececaeadaf4ac staff-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 staff-app/brand-logo.png -6c7869affeaa1ac2157debd08b86a4b98caf0d1e259a4d333d44868dc331a87f customer-app/index.html -9b585ef27ecb08883f88447435972db6b5afe299ee868aad93053b9848e9dce0 customer-app/sw.js +99bbf1ed552acee71d120631882fdf8cc49b7875b38c33bc2e2f78ecb108e74a customer-app/index.html +7af7d140b7a4af4acf7c2d6fad7f720a4cee13f1dfccff731356df737d44a259 customer-app/sw.js 3bfb1fd10cc13f09ca6be65c461e1f6b5750ae51a3ece12e079750b2a066052e customer-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 customer-app/brand-logo.png -6f4e68f50b337330f69d1bd2d86d9c6017cf4b23234421799bddef3ed8d867b9 display-app/index.html -ce398f84cf78f787c615332dae2c141c8beacd338a9bb06de319d0685cc9dd4b display-app/sw.js +10c08c34995b70fdd143fdfe990189a5fdb24964a98de3f3329af7ea53369ba1 display-app/index.html +1247ef8f2fa96928179882c12f62eda5de1b6ffbcab6da7a0a049c6b34a80150 display-app/sw.js 35e2721b86eb1ae1605e55bee64177adcee72f4e53a24ac417d19ea2873434a1 display-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 display-app/brand-logo.png -e59658caf2226a5c5c3b67b53694f780c70851149e5e6933733681d21c3bf1cb chef-app/index.html -fd9c4adf7a9361aa0e25c71d0f2ae46c34630441c606290a232d5a04c670c831 chef-app/sw.js +6b32c9c37b5ac6b1c8799a1862b7eff8515af3522bd33f1423e8314e4fe6287a chef-app/index.html +451e5ef642087f432f8afcd5e08ee09a1d77af1101e67a3a774c59c64e1814b6 chef-app/sw.js 97ed43decde8a888e22b7411e13a2122c6f8b9944cf38b2e28e8f62ef2e25397 chef-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 chef-app/brand-logo.png diff --git a/car-app/_expo/static/js/web/bundle.js b/car-app/_expo/static/js/web/bundle.js index 2b55df46390a9c1a5d04519c3578e4e3c7adda44..1a1c443106d7c1df47fccc78cff8b623304551cb 100644 --- a/car-app/_expo/static/js/web/bundle.js +++ b/car-app/_expo/static/js/web/bundle.js @@ -6,11 +6,11 @@ var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow() __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},0,[1,2]); __d(function(g,r,i,a,m,e,d){},1,[]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0])},2,[3]); -__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1618]); +__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1621]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},4,[5,6]); __d(function(g,r,i,a,m,e,d){},5,[]); __d(function(g,r,i,a,m,e,d){const _='undefined'==typeof window;globalThis.__webpack_chunk_load__=_=>g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},6,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1614,1617]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1617,1620]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},8,[9]); __d(function(g,r,i,a,m,e,d){ /** @@ -24,7 +24,7 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},9,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},10,[11]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1566,1571,1572,1613]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1569,1574,1575,1616]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},12,[13,17,775,856,955,8]); __d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return Object.keys(t).forEach(function(c){"default"===c||Object.prototype.hasOwnProperty.call(n,c)||Object.defineProperty(n,c,{enumerable:!0,get:function(){return t[c]}})}),t}Object.defineProperty(e,"__esModule",{value:!0}),r(d[0]),t(r(d[1]),e),t(r(d[2]),e),t(r(d[3]),e),t(r(d[4]),e)},13,[14,15,765,766,768]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},14,[]); @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); @@ -1485,8 +1485,8 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1403,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1404,[13,17,1405,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1542,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1455,1462,1463,1464,1184,1237,1465,1446,1466,1468,1444,1155,1480,1220,1382,1222,1235,1470,1082,1084,1538,1539,1558,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1545,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1460,1467,1468,1469,1184,1237,1470,1446,1471,1473,1444,1155,1485,1220,1382,1222,1235,1475,1082,1084,1541,1542,1561,8]); __d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:O}={}){const{rid:ne,r:ie,now:ae,today:oe,me:de,role:re}=(0,w.useCtx)(1e4),ue=(0,_.useBookings)(ne),ce=(0,w.useInStaffApp)(),he=(0,w.useShiftManager)(),ge=(0,_.useWaitlist)(ne),[be,pe]=((0,_.useStore)(e=>e.alertAcks),(0,P.useState)(oe)),ke=(0,U.useFrontDoor)(be),xe=(0,y.useBookingWrite)(),me=(0,f.useSeatClearFinish)(),[we,ye]=(0,P.useState)(''),[je,fe]=(0,P.useState)(!1),[Ie,Be]=(0,P.useState)(2),De=bee.date===be).sort((e,s)=>e.time.localeCompare(s.time)),$e=ge.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=Se.filter(e=>'noshow'===e.status),Ce=(0,Z.useSync)(e=>!!e.venueId&&'guest'!==e.kind),Le=Se.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),ve=(0,p.cancelledDayTally)(ue,be),Ne=(0,p.cancelledTallyWords)(ve,be===oe?'today':'that day'),Pe=Se.filter(e=>!e.walkIn),Oe=Se.filter(e=>e.walkIn),We=ue.filter(e=>'pending'===e.status&&e.date>=oe).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Me,Ee]=(0,P.useState)(null),Ae=(0,z.parseYmd)(be);Ae.setHours(12);const Re=(0,te.hoursFor)(ie,Ae),ze=Re?.open??new Date(`${be}T12:00:00`),He=Re?.close??new Date(`${be}T21:00:00`),Ge=Re||Se.length?De?'No one seated that day':be===oe?'No bookings yet today':'No bookings yet':be===oe?'Closed today':'Closed that day',Fe=$e.length>0||je||'waitlist'===O?(0,le.jsxs)(W.default,{style:{gap:10},children:[(0,le.jsx)(F.SectionHead,{title:`Waitlist (${$e.length})`,sub:`New party waits about ${(0,H.estimateWait)($e.length+1,ie.settings.turnMins,1)} min (estimate)`}),$e.map((e,s)=>(0,le.jsxs)(W.default,{style:M.styles.card,children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,le.jsxs)(M.Muted,{children:[(0,z.minsBetween)(new Date(e.joinedAt),ae)," min \xb7 est. ",(0,H.estimateWait)(s+1,ie.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,le.jsx)(M.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,le.jsxs)(M.Row,{gap:6,children:['waiting'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>_.repo.waitlist.setStatus(e.id,'notified')}):null,me.ok?(0,le.jsx)(M.Button,{small:!0,label:"Seat",onPress:()=>_.repo.waitlist.setStatus(e.id,'seated')}):null,(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>_.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:we,onChangeText:ye,style:[M.styles.input,{flex:1}]}),(0,le.jsx)(M.Stepper,{value:Ie,onChange:Be,min:1,max:12,label:"party"})]}),(0,le.jsx)(M.Button,{kind:"secondary",label:"Add to waitlist",disabled:we.trim().length<2,onPress:()=>{_.repo.waitlist.join(ne,we.trim(),Ie),ye('')}})]}):(0,le.jsx)(M.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>fe(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===O?(0,le.jsx)(W.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Fe}):(0,le.jsxs)(W.default,{style:{gap:12},children:[(0,le.jsx)(l.BookingSaveBanner,{rid:ne}),e&&!ce&&'staff'!==re?(0,le.jsx)(M.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===ne)&&!ce&&'staff'!==re?(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"table"}):null,!s.IS_WILDINGS&&!ie.settings.hotel?.enabled||ce||'staff'===re?null:(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"room",hotel:ie.settings.hotel??n.WILDINGS_HOTEL}),(0,le.jsx)(q.BookingsDayNav,{today:oe,date:be,onDate:pe,count:e=>ue.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ue.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,le.jsx)(W.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,le.jsx)(se.DayGraph,{bare:!0,fill:!0,todays:Se,open:ze,close:He,now:ae,turnBase:ie.settings.turnMins,height:128,past:De,closed:!Re,emptyText:Ge})}),De?(0,le.jsxs)(W.default,{testID:"bookings-past-totals",style:[M.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,q.longDay)(be)}: ${Pe.length} tables, ${Le} Covers, ${Se.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${Se.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,le.jsxs)(M.T,{size:17,weight:"semibold",children:["That day: ",Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']}),(0,le.jsxs)(M.T,{size:16,colour:G.colours.text,children:[Se.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",Se.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,le.jsx)(M.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,le.jsx)(W.default,{testID:"bookings-summary",children:(0,le.jsxs)(M.T,{weight:"semibold",children:[Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']})}),ce||'staff'===re||De?null:(0,le.jsx)(h.BookingsMatchStatus,{}),(0,le.jsx)(W.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ne,style:{alignItems:'center'},children:(0,le.jsx)(M.T,{size:15,colour:G.colours.muted,center:!0,children:Ne})}),(0,le.jsxs)(W.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[De||ce&&!he?null:(0,le.jsx)(T.QuietButton,{label:"New booking",onPress:ke.openBooking,testID:"add-booking",disabled:!xe.ok,accessibilityHint:xe.hint}),ce&&he&&be===oe?(0,le.jsx)(T.QuietButton,{label:"Walk-in",onPress:ke.openWalkIn,testID:"add-walkin",disabled:!xe.ok,accessibilityHint:xe.hint}):null,be===oe?(0,le.jsx)(C.CloseGardenButton,{quiet:!0,short:!0,rid:ne,r:ie,now:ae,by:de}):null]}),We.length?(0,le.jsxs)(W.default,{testID:"pending-requests",style:[M.styles.card,{borderColor:G.colours.amber,gap:8}],children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:G.colours.amber,children:["Needs confirming (",We.length,")"]}),(0,le.jsx)(M.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),We.map(e=>(0,le.jsxs)(W.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:G.colours.border},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,le.jsxs)(M.Muted,{children:[(0,z.niceDate)((0,z.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,le.jsxs)(M.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie}),'staff'!==re&&((0,v.needsHoldOk)(e)||e.date===oe&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,v.needsHoldOk)(e)?(0,le.jsx)(M.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,L.confirmHolds)(e.id,de)}):null,e.holdOk&&'seated'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,L.serveHolds)(e,de,'owner')}):null]}):null,Me===e.id?(0,le.jsxs)(W.default,{style:{gap:6},children:[(0,le.jsxs)(M.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{_.repo.bookings.decide(e.id,'declined',de),Ee(null)}}),(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ee(null)})]})]}):xe.ok?(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>_.repo.bookings.decide(e.id,'confirmed',de)}),(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ee(e.id)}),(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"change"})]}):(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),(0,le.jsx)(J.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Se.length?(0,le.jsx)(M.Muted,{children:"No bookings for this day yet."}):null,Se.map(e=>{const s='confirmed'===e.status&&be===oe&&(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,R.gbp);return(0,le.jsxs)(W.default,{testID:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[M.styles.card,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,N.seatedHighlightStyle)({borderColor:(0,v.hasAllergens)(e)?G.colours.red:G.colours.goldLight}):{borderColor:(0,v.hasAllergens)(e)?G.colours.red:s?G.colours.amber:G.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,le.jsx)(L.AllergenBar,{b:e}),(0,le.jsx)(l.BookingNotSavedLine,{b:e}),(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?N.SEATED_FG:G.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,v.hasAllergens)(e)?(0,le.jsx)(E.AllergyIcon,{text:(0,v.allergenText)(e),size:20,colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?'#7A4A00':G.colours.amber,ink:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?G.colours.gold:G.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,le.jsx)(M.Badge,{kind:'seated'===(0,v.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,v.shownStatus)(e)[0].toUpperCase()+(0,v.shownStatus)(e).slice(1)})]}),n?(0,le.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,le.jsxs)(M.T,{size:14,colour:N.SEATED_MUTED,children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,le.jsxs)(M.Muted,{children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,le.jsxs)(M.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,le.jsx)(M.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie,only:"rules"}),(0,b.historyLines)(e)[0]?(0,le.jsxs)(M.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[De||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>_.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:de,depositPaidAt:(new Date).toISOString()})}),De?null:(0,le.jsx)(S.WixDepositLink,{b:e,rid:ne}),De||!xe.ok||ce&&!he?null:(0,le.jsx)(D.WaiveDepositButton,{b:e,who:de,small:!0}),'waived'===t&&e.depositWaived?(0,le.jsx)(M.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,le.jsx)(M.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,le.jsxs)(M.Muted,{children:[(0,X.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,v.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,le.jsx)(Q.BookingAllergyChain,{b:e,me:de}):null,e.walkIn?null:(0,le.jsx)(J.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,le.jsxs)(M.T,{size:13,colour:G.colours.amber,children:["Running ",(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)," min late. Call them, then mark no-show if needed."]}):null,xe.ok?(0,le.jsx)(c.BookingEditButton,{rid:ne,booking:e,who:de,role:re,inStaffApp:ce,shiftManager:he,big:!0,testID:`edit-booking-${e.id}`}):null,(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,le.jsx)(u.BookingTableButton,{rid:ne,booking:e,readOnly:De||!xe.ok,turnBase:ie.settings.turnMins,canClear:me.ok}),xe.ok?null:(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),xe.ok?(0,le.jsxs)(le.Fragment,{children:[De||e.table||!['seated','confirmed'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>ke.assignTable(e)}),!De&&['seated','confirmed'].includes(e.status)?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>ke.combineTables(e)}):null,De||'confirmed'!==e.status?null:(0,le.jsxs)(le.Fragment,{children:[me.ok&&e.date===oe?(0,le.jsx)(M.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(ne,e)}):null,(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>_.repo.bookings.setStatus(e.id,'noshow')})]}),De||e.walkIn?null:(0,le.jsx)(r.CancelBookingButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),De||e.walkIn?null:(0,le.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:oe}),De||'seated'!==e.status?null:(0,le.jsx)(K.FinishButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),allowed:me.ok,hint:me.hint,small:!0,a11y:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=oe?(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"auto"}):null,ce?null:(0,le.jsx)($.CopyReviewLink,{rid:ne,bookingId:e.id}),!De&&e.walkIn?(0,le.jsx)(d.CancelWalkInButton,{rid:ne,b:e,small:!0}):null,!De&&e.walkIn?(0,le.jsx)(d.ReinstateWalkInButton,{rid:ne,b:e,today:oe,small:!0}):null,(0,le.jsx)(Y.BookingUndo,{b:e,rid:ne,today:oe,who:(0,U.walkInLabel)(e),allowed:me.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,le.jsx)(M.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,le.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ue,be,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:be===oe?'today':'that day'}),(0,le.jsxs)(M.Card,{children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsx)(M.T,{weight:"semibold",children:"No-shows"}),(0,le.jsx)(M.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${be===oe?'today':(0,z.niceDate)((0,z.parseYmd)(be)).slice(0,6)}${Ce||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,le.jsx)(M.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${Te.length>6?` and ${Te.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,le.jsx)(t.GreensideCashOnly,{}):(0,le.jsxs)(M.Card,{children:[(0,le.jsx)(M.T,{weight:"semibold",children:"Deposits"}),(0,le.jsx)(M.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ie.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,le.jsx)(M.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Fe,ke.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),w=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=(e=O)&&e.__esModule?e:{default:e},M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),F=_r(_d[40]),U=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53])},1407,[805,1408,1093,1261,1409,812,822,1113,1114,1089,1118,1410,1119,1115,1395,1396,1055,1331,994,1116,1087,841,1122,1412,1231,1413,1387,1076,1053,1088,17,85,777,1353,858,845,851,863,1313,804,1178,1096,1111,996,1348,1060,1156,1414,1222,946,1180,1392,862,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1408,[]); __d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1409,[806,17,85,777,946,1265,8]); @@ -1500,7 +1500,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1417,[17,278,85,777,857,804,1418,8]); __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1418,[]); __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{background-image:radial-gradient(1.2px 1.2px at 23px 41px,#fff,transparent),radial-gradient(1px 1px at 97px 13px,#fff9,transparent),radial-gradient(1.4px 1.4px at 151px 120px,#f5e6c8,transparent),radial-gradient(1px 1px at 61px 163px,#fffa,transparent),radial-gradient(1.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1419,[888,813,17,1067,319,219,385,278,24,85,856,885,876,816,946,966,878,776,804,884,777,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ae,me:ne,today:ie}=(0,A.useCtx)(5e3),re=(0,p.useOrders)(n),de=(0,p.useBookings)(n),ce=(0,p.useWaitlist)(n),he=(0,p.useEvents)(n),ye=(0,p.useRatings)(n),xe=(0,j.useOwner)(e=>e.staff),me=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),be=(0,j.useOwner)(e=>e.shifts),fe=(0,M.useRealHistory)(n,F),pe=(0,l.useMemo)(()=>(0,s.forecastToday)(x,de,re,he,F,fe??void 0),[x,de,re,he,fe,F.getTime()/6e4|0]),je=(0,S.useExamples)(),ke=(0,N.useCashUp)(e=>e.cashUps),we=de.filter(e=>e.date===ie),$e=re.filter(B.LIVE),ve=ce.filter(e=>'waiting'===e.status||'notified'===e.status),Ie=(0,C.seatedCoversOn)(de,ie),Ce=(0,oe.coversSplit)(we,ie),De=$e.filter(e=>(0,_.chainNeedsAction)(e,de)),Te=we.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,$e)),Be=$e.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Ae=pe.nextHour,Le=(0,B.busyLevel)(Ae?.coversHigh??0,pe.busy.busy),Me=(0,B.restOfDayLevel)(pe,x),Se=re.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===ie).reduce((e,t)=>e+t.paid,0),Ne=(0,R.tradingDay)(F),Pe=je?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Fe=je?{today:186e3+Se,last:Pe?{date:(0,I.ymd)(Pe.date),pence:Pe.total}:null,online:0,show:!0}:(0,O.takingsToday)(ke,n,Ne,Se),We=j.CAN.takings(ae)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),He=(0,l.useMemo)(()=>(0,L.insights)(x,de,re,he,ye,F,Ie),[x.id,de.length,ye.length,Ie]),Re=((0,A.weekday)(F),(0,k.openWorkingRows)(me,ie)),Oe=(0,ee.useFrontDoor)(ie),ze=(0,u.useBookingWrite)(),Ee=(0,w.useOutstanding)(),Ge=(0,i.useTravelDay)('owner',ie),Ue=(0,A.useSignedIn)(),qe=(0,A.useInStaffApp)(),Ye=(0,P.canSeeMonthTakings)(ae,Ue,{inStaffApp:qe,live:(0,H.isLive)()}),Ke=(0,W.homeSetupNagsHidden)(n),Ve=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Qe,Xe]=(0,l.useState)(!1),[Ze,Je]=(0,l.useState)(!1),et=ne.replace(' (example)',''),tt=j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ge?(0,le.jsxs)(b.default,{style:{gap:12},children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(i.DayView,{rid:n,day:Ge,today:ie,app:"owner"})]}):(0,le.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(V.AssistantPendingCard,{}),Ue&&'owner'!==Ue.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,Ue?(0,le.jsx)(X.MyTasksToday,{rid:n,staffId:Ue.id,name:Ue.name,onShift:(0,J.shiftNow)(Ue.id,Date.now()).on}):null,'staff'!==ae?(0,le.jsx)(Z.TodaysTipsCard,{rid:n,today:ie}):null,'staff'!==ae?(0,le.jsx)(Z.TipsPotCard,{rid:n,today:ie}):null,j.CAN.manage(ae)?(0,le.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,le.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,le.jsx)(ge,{split:Ce}),(0,le.jsx)(te.BlocksBanner,{rid:n,now:F,by:ne}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ie,by:ne,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ke?(0,le.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ke?(0,le.jsx)(o.SeasonsTodo,{go:e}):null,(0,le.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Xe(!0),style:{minHeight:56}}),(0,le.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(c.QuietButton,{label:"New booking",onPress:Oe.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),j.CAN.manage(ae)?(0,le.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ne}):null]}),Oe.elements,j.CAN.manage(ae)?(0,le.jsx)(Y.PaydaysCard,{go:e}):null,(0,le.jsx)(E.FadeIn,{children:(0,le.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Ae?` \xb7 ${(0,A.fmtH)(Ae.hour)}\u2013${(0,A.fmtH)(Ae.hour+1)}`:'']}),pe.example?(0,le.jsx)(M.ExampleBadge,{}):pe.enough?(0,le.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(E.Gauge,{pct:Ae?Le.pct:0,label:Ae?Le.label:pe.open?'Kitchen closing':'Closed today',sub:Ae&&!pe.enough?`${Ae.booked} booked${Ae.walkIns?` + ${Ae.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Ae?`Estimated ${(0,s.coversRange)(Ae.coversLow,Ae.coversHigh)} \xb7 Busy at ${pe.busy.busy} Covers an hour \xb7 ${Ae.booked} booked + about ${Ae.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Ae.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[pe.enough?(0,le.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,pe.enough?(0,le.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(pe.restOfDay.low,pe.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${pe.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${pe.restOfDay.booked} Covers`})]}),pe.flags.length?(0,le.jsxs)(f.Muted,{center:!0,children:["Calendar: ",pe.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||$e.length?(0,le.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Live orders",value:"",accent:$e.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${$e.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${$e.filter(e=>'table'===e.type).length} table`:`${$e.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(E.CountUp,{value:$e.length})})}):null,ve.length>0?(0,le.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,le.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,le.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(z.TakingsTodayCard,{t:Fe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:De.length+Te.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(E.CountUp,{value:De.length+Te.length,colour:De.length+Te.length?T.colours.red:T.colours.ok})})})]}),De.length+Te.length+Be.length?(0,le.jsx)(B.SectionHead,{title:"Needs action now"}):null,De.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ne,compact:!0})]},e.id)),Te.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ne})]},e.id)),Be.map(t=>(0,le.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(f.T,{size:14,children:t.detail}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ee.days.length||Ee.requests)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ee.days.length?`${Ee.days.length} earlier day${Ee.days.length>1?'s':''} to sign off`:''}${Ee.days.length&&Ee.requests?' \xb7 ':''}${Ee.requests?`${Ee.requests} correction request${Ee.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&j.CAN.publishSocial(ae)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(B.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(f.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(B.SectionHead,{title:e})}),(0,le.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(f.Badge,{kind:"ok",label:`${Re.length} clocked in`})}),(0,le.jsxs)(f.Card,{children:[0===Re.length?(0,le.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Re.map(e=>{const t=xe.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(be,e.staffId,ie),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,le.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,le.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,le.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ae?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(B.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((t,s)=>(0,le.jsx)(E.FadeIn,{delay:100+90*s,children:(0,le.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,le.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,le.jsx)(f.Muted,{children:t.body}),t.action?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ye?(0,le.jsx)(f.Button,{testID:"home-takings-button",kind:Ze?'secondary':'primary',label:Ze?'Hide takings':'Takings',accessibilityLabel:Ze?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>Je(e=>!e),style:{minHeight:56}}):null,Ye&&Ze?(0,le.jsx)(E.FadeIn,{children:(0,le.jsx)(ue,{rid:n,today:ie})}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Qe,onClose:()=>Xe(!1),rid:n,by:et,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ce,_e.MonthTakingsCard=ue,_e.WalkInSplitCard=ge;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]);const ae=18,ne=18,ie=150,re=34;function de(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sae+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function ue({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ce(k,r):[],z=(e,t,s,l,a)=>(0,le.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,le.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,le.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,le.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,le.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,le.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,le.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,le.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,le.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ie,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:ae,y1:$,x2:r-ne,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:`${de(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:de(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,le.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,le.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,le.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,le.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ie,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,le.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:re,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,le.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const he='#3A2F1E';function ge({split:e}){return(0,le.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:he,borderWidth:1,borderColor:T.colours.gold},children:[(0,le.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,le.jsx)(b.default,{style:{flex:1,backgroundColor:he}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ne,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(n),ce=(0,p.useBookings)(n),ue=(0,p.useWaitlist)(n),ge=(0,p.useEvents)(n),xe=(0,p.useRatings)(n),me=(0,j.useOwner)(e=>e.staff),be=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),fe=(0,j.useOwner)(e=>e.shifts),pe=(0,M.useRealHistory)(n,F),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,F,pe??void 0),[x,ce,de,ge,pe,F.getTime()/6e4|0]),ke=(0,S.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),ve=de.filter(B.LIVE),Ie=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=ve.filter(e=>(0,_.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,ve)),Ae=ve.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Me=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Se=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(F),Fe=ke?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,We=ke?{today:186e3+Ne,last:Fe?{date:(0,I.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,n,Pe,Ne),He=j.CAN.takings(ne)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,F,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(F),(0,k.openWorkingRows)(be,re)),ze=(0,ee.useFrontDoor)(re),Ee=(0,u.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,i.useTravelDay)('owner',re),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,P.canSeeMonthTakings)(ne,qe,{inStaffApp:Ye,live:(0,H.isLive)()}),Ve=(0,W.homeSetupNagsHidden)(n),Qe=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Xe,Ze]=(0,l.useState)(!1),[Je,et]=(0,l.useState)(!1),tt=ie.replace(' (example)',''),st=j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,ae.jsxs)(b.default,{style:{gap:12},children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(i.DayView,{rid:n,day:Ue,today:re,app:"owner"})]}):(0,ae.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(K.WhoBar,{}),(0,ae.jsx)(V.AssistantPendingCard,{}),qe&&'owner'!==qe.role?(0,ae.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ae.jsx)(X.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ne?(0,ae.jsx)(Z.TodaysTipsCard,{rid:n,today:re}):null,'staff'!==ne?(0,ae.jsx)(Z.TipsPotCard,{rid:n,today:re}):null,j.CAN.manage(ne)?(0,ae.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ae.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,ae.jsx)(le.SuperProInsights,{go:e}),(0,ae.jsx)(ye,{split:De}),(0,ae.jsx)(te.BlocksBanner,{rid:n,now:F,by:ie}),(0,ae.jsx)(y.KitchenSignoffs,{rid:n,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ne)}),j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(o.SeasonsTodo,{go:e}):null,(0,ae.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,ae.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:Ee.hint,disabled:!Ee.ok,onPress:()=>e('more','blocks')}):null,(0,ae.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,ae.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ae.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ne)?(0,ae.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ie}):null]}),ze.elements,j.CAN.manage(ne)?(0,ae.jsx)(Y.PaydaysCard,{go:e}):null,(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Le?` \xb7 ${(0,A.fmtH)(Le.hour)}\u2013${(0,A.fmtH)(Le.hour+1)}`:'']}),je.example?(0,ae.jsx)(M.ExampleBadge,{}):je.enough?(0,ae.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ae.jsx)(E.Gauge,{pct:Le?Me.pct:0,label:Le?Me.label:je.open?'Kitchen closing':'Closed today',sub:Le&&!je.enough?`${Le.booked} booked${Le.walkIns?` + ${Le.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Le?`Estimated ${(0,s.coversRange)(Le.coversLow,Le.coversHigh)} \xb7 Busy at ${je.busy.busy} Covers an hour \xb7 ${Le.booked} booked + about ${Le.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Le.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ae.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Se.level.label}${Se.peak?`, peak ${(0,A.fmtH)(Se.peak.hour)}`:''}`}):null,je.enough?(0,ae.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(je.restOfDay.low,je.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${je.restOfDay.takeaway} takeaways`:''}`}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ae.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||ve.length?(0,ae.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Live orders",value:"",accent:ve.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${ve.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${ve.filter(e=>'table'===e.type).length} table`:`${ve.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ae.jsx)(E.CountUp,{value:ve.length})})}):null,Ie.length>0?(0,ae.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${Ie.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ae.jsx)(E.CountUp,{value:Ie.length})})}):null,He&&We.show?(0,ae.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(z.TakingsTodayCard,{t:We,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ae.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:Te.length+Be.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,ae.jsx)(E.CountUp,{value:Te.length+Be.length,colour:Te.length+Be.length?T.colours.red:T.colours.ok})})})]}),Te.length+Be.length+Ae.length?(0,ae.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ae.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ae.jsx)(f.T,{size:14,children:t.detail}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ne)&&(Ge.days.length||Ge.requests)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,ae.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ne)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ae.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ae.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ae.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,ae.jsxs)(f.Row,{gap:4,children:[(0,ae.jsx)(G.Mark,{p:"facebook"}),(0,ae.jsx)(G.Mark,{p:"instagram"}),(0,ae.jsx)(G.Mark,{p:"tiktok"}),(0,ae.jsx)(G.Mark,{p:"youtube"})]}),(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ae.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ae.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ae.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ae.jsx)(B.SectionHead,{title:e})}),(0,ae.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ae.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ae.jsxs)(f.Card,{children:[0===Oe.length?(0,ae.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Oe.map(e=>{const t=me.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(fe,e.staffId,re),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,ae.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ae.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ae.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ae.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ne?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(B.SectionHead,{title:"Insights",sub:ke?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),Re.slice(0,4).map((t,s)=>(0,ae.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ae.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,ae.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,ae.jsx)(f.Muted,{children:t.body}),t.action?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ke?(0,ae.jsx)(f.Button,{testID:"home-takings-button",kind:Je?'secondary':'primary',label:Je?'Hide takings':'Takings',accessibilityLabel:Je?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>et(e=>!e),style:{minHeight:56}}):null,Ke&&Je?(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsx)(he,{rid:n,today:re})}):null,(0,ae.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:tt,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ue,_e.MonthTakingsCard=he,_e.WalkInSplitCard=ye;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]),ae=_r(_d[56]);const ne=18,ie=18,re=150,de=34;function ce(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sne+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function he({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yne+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ue(k,r):[],z=(e,t,s,l,a)=>(0,ae.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,ae.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ae.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ae.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,ae.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,ae.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ae.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,ae.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ae.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ae.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ae.jsxs)(n.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ae.jsx)(a.Defs,{children:(0,ae.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ae.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ae.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ae.jsx)(a.Line,{x1:ne,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:`${ce(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:ce(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,ae.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ae.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,ae.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,ae.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ae.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ae.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ae.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ae.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ae.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ae.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,ae.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ae.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ae.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ae.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,ae.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ae.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ae.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ge,borderWidth:1,borderColor:T.colours.gold},children:[(0,ae.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ae.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,1455,8]); __d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:$}=(0,D.useCtx)(6e4),V=$.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsx)(j.Toggle,{label:`${e.name}: no deposit, paid on the night`,value:!!e.payOnNight,onChange:s=>pe(e.id,{payOnNight:s})}),e.payOnNight?null:(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Pre-order deposit each"}),(0,W.jsx)(K,{label:`${e.name} pre-order deposit`,min:0,max:200,value:Math.round((e.depositPence??0)/100),unit:e=>e?`\xa3${e}`:'None',onChange:s=>pe(e.id,{depositPence:100*s||void 0})})]}),(0,W.jsx)(j.Muted,{size:12,children:e.uses.length?`Uses: ${e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')} from the counted stock. Held from the Display count and shown as \u201cReserved\u201d.`:'Not taken from the counted stock.'})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),Re=J.hourOverrides??[],De=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:R.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),De?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:De}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!De,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),Re.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:Re.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...Re.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),$e=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,ze]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{ze(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From this many adults"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from this many adults"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:R.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more adults see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)(z.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:$e,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:R.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:R.colours.accentBorder,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:R.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:R.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,D.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:R.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:R.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:R.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),$=_r(_d[31]),I=_r(_d[32]),z=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:R.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?R.colours.red:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:R.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:R.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:R.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:R.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,$.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:R.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1421,[1051,1031,805,1408,812,1422,1423,1425,1426,1427,1197,1029,1030,1006,1012,17,385,85,777,841,1428,816,862,1053,861,804,1055,858,1181,972,973,876,1429,1382,996,1430,1003,1139,939,8]); __d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1422,[812,17,85,777,1137,861,804,8]); __d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1423,[843,17,219,85,777,858,996,1150,1254,946,1325,1424,8]); @@ -1535,170 +1535,173 @@ __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule' __d(function(_g,_r,i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1452,[17,264,385,85,777,804,961,1453,8]); __d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1453,[892,946,876,856,961]); __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssistantPendingCard=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),t=b(),[n,o]=(0,s.useState)(null),l=async()=>{try{o(await(0,r.assistantProposalsList)())}catch{o([])}};return(0,s.useEffect)(()=>{if(!e||!t)return;l();const s=setInterval(()=>{l()},2e4);return()=>clearInterval(s)},[e,t]),e&&t?(0,u.jsx)(y,{rows:n,onChanged:()=>{l()},compact:!0}):null},_e.AssistantsPage=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[t,l]=(0,s.useState)(''),[h,b]=(0,s.useState)(null),[x,f]=(0,s.useState)(!1),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),[v,D]=(0,s.useState)(null),I=async()=>{try{w(await(0,r.assistantList)())}catch{w([])}try{T(await(0,r.assistantProposalsList)())}catch{T([])}};(0,s.useEffect)(()=>{e&&I()},[e]);const C=t.replace(/\D/g,''),P=async()=>{f(!0),b(null);const e=await(0,r.assistantApprove)(C);f(!1),e.ok?(l(''),b({ok:!0,text:'Done. Tracy\u2019s assistant is paired. It can look things up and propose changes, which wait for Tracy to confirm on her phone.'}),I()):b({ok:!1,text:e.message})};return(0,u.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,u.jsx)(y,{rows:k,onChanged:()=>{I()}}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair Tracy\u2019s assistant"}),(0,u.jsx)(o.T,{center:!0,children:"Ask Tracy\u2019s Grok Bot to start CoverCharge sign-in. It will show 6 numbers."}),(0,u.jsx)(o.T,{center:!0,children:"Only an owner can approve this. The bot can look things up and advise, and it can propose a change. Nothing is changed until Tracy confirms it on her phone. Important changes \u2014 permissions, opening hours, the table plan, cancelling or moving a booking, pay, menus, stock or price, online settings, or any delete \u2014 ask her a second time, with a plain warning of what is affected."}),(0,u.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:t,onChangeText:e=>l(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,u.jsx)(o.Button,{testID:"assistant-approve",label:x?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs Tracy\u2019s Grok Bot as an assistant for The Anchorage",disabled:!e||x||6!==C.length,onPress:()=>{P()},style:{minHeight:56}}),e?null:(0,u.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,u.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!h,accessibilityLabel:h?.text,children:h?(0,u.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:h.ok?c.colours.goldLight:c.colours.amber,children:h.text}):null}),(0,u.jsx)(o.Muted,{center:!0,children:"Never send Tracy\u2019s personal app link to the bot. That link stays on her phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, and it cannot change its own access or pairing."})]}),(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,u.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,u.jsx)(o.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,u.jsx)(o.Button,{testID:`assistant-revoke-${e.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>D(e),style:{minHeight:56}})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),v?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>D(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,u.jsx)(o.T,{center:!0,children:`${v.label} stops working straight away. Any changes still waiting are cancelled. Tracy\u2019s phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,u.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=v;D(null);const s=await(0,r.assistantRevoke)(e.id);b(s.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:s.message}),I()},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>D(null),style:{minHeight:56}})]}):null]})};var e,s=_r(d[0]),t=_r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},o=_r(d[2]),r=_r(d[3]),l=_r(d[4]),c=_r(d[5]),h=_r(d[6]),u=_r(d[7]);const p=e=>e?`${(0,l.niceDate)(new Date(e))} at ${(0,l.hm)(new Date(e))}`:'not yet';function b(){const e=(0,h.useSignedIn)(),s=(0,r.useSync)(e=>e.staffRef);return'st-tracy'===e?.id||'st-tracy'===s}function y({rows:e,onChanged:t,compact:l}){const h=b(),y=(e??[]).filter(e=>'pending'===e.status),[x,f]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),v=async(e,s,n=!1)=>{f(e.id),w(null);const o=await(0,r.assistantProposalDecide)(e.id,s,n);f(null),o.ok?(T(null),w('decline'===s?'Declined. Nothing was changed.':'Done. The change has been made, as Tracy\u2019s assistant (confirmed by Tracy).'),t?.()):w(o.message)};return!y.length&&l?null:(0,u.jsx)(n.default,{testID:l?'assistant-pending-home':'assistant-pending-list',children:(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:h?'Waiting for you to confirm':'Waiting for Tracy to confirm'}),e?y.length?y.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,u.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${p(e.expiresAt)}.`:'']}):e.expiresAt?(0,u.jsx)(o.Muted,{center:!0,children:`Runs out at ${p(e.expiresAt)}.`}):null,h&&e.canDecide?(0,u.jsxs)(n.default,{style:{gap:8},children:[(0,u.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:x===e.id?'Working\u2026':'Approve',accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!x,onPress:()=>{e.needsDoubleConfirm?T(e):v(e,'approve')},style:{minHeight:56}}),(0,u.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",disabled:!!x,onPress:()=>{v(e,'decline')},style:{minHeight:56}})]}):(0,u.jsx)(o.Muted,{center:!0,children:"Only Tracy can confirm or decline this on her phone."})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,u.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),j?(0,u.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:j}):null,k?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>T(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:k.warning||k.summary}),(0,u.jsx)(o.T,{center:!0,children:"This is an important change to how the venue works. Please read it carefully, then confirm again. Nothing is changed until you do."}),(0,u.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:x===k.id?'Working\u2026':'Yes, make this change',disabled:!!x,onPress:()=>{v(k,'approve',!0)},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",disabled:!!x,onPress:()=>T(null),style:{minHeight:56}})]}):null]})})}},1454,[17,85,777,946,863,804,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1455,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1456,804,856,1055,1457,1460,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1456,[1032]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1457,[812,17,362,385,278,85,777,1458,1459,804,1455,1055,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1458,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1459,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1460,[17,385,85,777,860,1459,996,842,1461,1456,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1461,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1462,[813,17,266,347,219,385,85,831,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1463,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1464,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1465,[831]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1466,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1467,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1467,[17,85,777,858,851,946,804,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return fe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),A=_r(d[19]),R=_r(d[20]),T=_r(d[21]),M=_r(d[22]),O=_r(d[23]),G=_r(d[24]),B=_r(d[25]),E=_r(d[26]),x=_r(d[27]),I=_r(d[28]),D=_r(d[29]),L=(e=D)&&e.__esModule?e:{default:e},N=_r(d[30]),_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),pe=_r(d[59]),ge=_r(d[60]),he=_r(d[61]),be=_r(d[62]);const fe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},ye=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:ye,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>ye(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:ye,C:G.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:ye,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>ye(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:ye,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:ye,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:ye,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:ye,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:ye,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:ye,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:ye,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:ye,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:ye,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:ye,C:A.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:ye,C:R.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:ye,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:ye,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:ye,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:ye,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:ye,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:ye,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:ye,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:I.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>fe(),C:I.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:ye,C:I.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:ye,C:I.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:I.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:ye,C:I.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:ye,C:I.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:ye,C:I.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:ye,C:I.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:I.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>L.default.createElement(_.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:N.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:N.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:_.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:H.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:Q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:ye,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:ye,C:Q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:ye,C:q.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:ye,C:q.DisplaySettingsPage}]);const Ce=e=>'owner'===e||'manager'===e;F.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Ce,C:F.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Ce,C:F.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:W.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:U.AssistantsPage}]);const Se=e=>'owner'===e||'manager'===e,ke=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},ve=e=>Se(e)&&ke();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:Se,C:V.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:ve,C:V.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:ve,C:V.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:ve,C:V.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:Se,C:V.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:Se,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:V.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:ye,C:Y.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:ye,C:Y.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:ye,C:Y.Outbox}]);const we=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:we,C:K.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:K.optinsAllowed,C:K.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:we,C:z.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:we,C:j.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:we,C:$.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:we,C:J.OrderSheetSettings},...X.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:we,C:(0,j.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:we,C:Z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:we,C:ee.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:ye,C:ee.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:we,C:ee.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:we,C:te.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:ye,C:se.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:ye,C:se.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:ye,C:se.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:ye,C:ae.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:ye,C:ie.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:ye,C:oe.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:ye,C:ne.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ne.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ue.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ce.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:Se,C:function(){const{rid:e,today:t}=(0,le.useCtx)(6e4);return L.default.createElement(ce.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:ye,C:re.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:ye,C:ge.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:ye,C:he.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:be.UseOnComputerPage}])},1468,[822,1048,856,1469,876,966,955,816,866,1471,1478,1486,1446,1487,1488,1490,1491,1155,1464,1492,1493,1495,1196,1187,1466,1496,1444,1497,1499,17,1193,1176,1445,1433,1447,1480,1504,1505,1454,1506,1436,1421,1507,1451,1508,886,1509,1510,1512,1182,1455,1513,1382,1457,1525,1079,1055,1197,1149,1528,1531,1534,1537]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1469,[17,378,219,385,85,19,777,1024,1327,876,804,1470,1184,1465,1055,8,260]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1470,[831]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1471,[812,1442,17,851,85,777,876,804,1055,884,885,1472,946,962,1029,1440,1473,1474,1476,994,1477,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1472,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1473,[812,17,85,777,804,876,1343,1342,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1474,[17,85,777,1475,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1475,[831,892,946,880]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1476,[17,85,777,804,960,1020,946,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1477,[892,946]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1478,[17,85,777,835,876,1479,804,1055,1480,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1479,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1480,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1481,1485,804,1055,1069,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1481,[1482,1484,1483]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1482,[843,1483]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1483,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1484,[1482,891]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1485,[869,824,831,834]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1486,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1487,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1488,[1037,17,85,1489,814,857,777,876,804,1055,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1489,[812,17,219,385,85,780,814,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1490,[17,1151,847,1055,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1491,[17,1030,1055,946,961,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1492,[17,1388,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1493,[17,85,780,777,858,1006,1494,804,1055,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1494,[839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1495,[17,85,1336,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1496,[17,776,1055,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1497,[17,85,777,858,1006,876,1053,1498,946,804,1232,1233,1055,8]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1498,[839,1494]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1499,[805,1408,812,822,843,1500,1427,1470,1218,841,1254,946,1501,1503,1428,17,1096,1478,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1500,[843,17,85,777,845,851,1150,858,853,804,8]); -__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1501,[946,17,264,219,85,1272,777,1251,1254,804,1502,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1502,[17,219,85,777,1251,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1503,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1504,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1505,[17,85,777,946,863,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1506,[813,812,822,17,219,385,85,777,1220,858,1485,848,1222,1016,804,1025,1055,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1507,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1508,[17,385,85,777,876,998,851,999,804,840,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1509,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1510,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1511,804,880,1157,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1511,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1512,[17,85,777,804,1423,1500,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1513,[812,1031,779,17,385,85,777,876,1462,1514,1515,1516,804,1055,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1514,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1515,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1516,[1517,1098,843,1518,1519,876,858,996,1462,1514,1515,1521,1520,1523,1524,994,995]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1517,[1062,1061,1021]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1518,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1519,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1520,1518]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1520,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1521,1522]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1521,[824,831,834]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1522,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1523,[816,876,956,851,1520,1015,1069]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1524,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1525,[17,362,85,777,804,1458,1521,1470,1522,1352,890,1526,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1526,[17,85,777,804,1527,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1527,[824,831,834]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1528,[17,779,85,777,845,1251,1529,1530,804,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1529,[845]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1530,[946,1529,1254]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1531,[17,85,777,858,1006,1532,938,839,1533,1018,804,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1532,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1533,[839,1007,1494]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1534,[812,17,85,777,1535,1019,804,1536,1055,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1535,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1536,[1018,1019,935,892,946]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1537,[17,264,219,85,777,812,804,946,1418,1182,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1538,[219]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1540,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1541,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1462,1084,1082,1222,1235,938,876,1030,1470,880,946,804,1327,1542,1055,1480,1407,1155,1464,1466,1455,1446,1468,1538,1540,1548,1549,1550,1553,1556,8]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1542,[17,266,347,219,385,278,85,409,780,779,1327,1446,1468,1407,1155,1466,1464,1055,1024,777,858,876,863,946,880,804,1543,1544,1545,1546,1547,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1543,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1544,[17,780,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1545,[17,85,777,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1546,[17,385,1157,1158,816,805,777,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1547,[17,219]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1548,[1543]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1549,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1550,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1551,1540,1549,1552,8]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1551,[17,385,278,85,777,804,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1552,[17,85,780,777,804,1551,1549,8]); -__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1553,[17,264,385,85,780,777,858,876,1554,961,1208,1453,804,1544,1055,1551,1555,1549,1552,1550,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1554,[831,834,824]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1555,[961]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1556,[17,85,777,804,1557,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1557,[]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1558,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1462,1085,1084,1082,1470,1222,880,804,1480,1407,1155,1055,1420,1464,1455,1466,1446,1468,1559,1538,1561,1563,1565,1562,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1559,[17,278,85,1489,857,777,876,814,1447,804,1560,1561,1562,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1560,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1561,[17]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1562,[17,85,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1563,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1560,1561,1562,1564,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1564,[876]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1565,[17,85,777,876,1058,804,1560,1561,1562,1049,1564,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1566,[13,17,856,1567,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1567,[1447,1568,813,958,1070,1500,1202,1203,1026,1023,1024,1501,1528,1503,1149,938,979,1569,976,880,1029,1030,1476,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1492,1487,1510,1570,1415,966,219,1237,1176,1182,1445,1196,1193,1463,1179,878,1205,1206,884,776,946,8]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1568,[17,85,777,1055,946,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1569,[219,977]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1570,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[13,17,856,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1572,[1440,946,778,1401,1573,993,13,1600,479,17,368,319,219,24,85,805,857,1063,856,1602,19,858,996,876,804,1415,966,987,1603,1604,1026,1605,1102,880,1006,960,1608,1372,8,1609,1610,1611,1612]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1573,[1574,1597,1599]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1574,[198,1575,1578,1592,1593,1594,1595,1596]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1575,[198,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1576,[1577]); -__d(function(g,r,i,a,m,e,d){},1577,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1578,[1579,198,1575,1592,1593]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1579,[1580,1581,1591]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1580,[1581,1585,1590]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1581,[198,355,1582,1586,1587,1588,1589,1585,1590]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1582,[198,1583,322,263,1584,1585]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1583,[487]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1584,[198,322]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1585,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1586,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1587,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1588,[1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1589,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1590,[355,1584]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1591,[17,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1592,[1579,198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1593,[1579,1592]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1594,[1575]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1595,[198,1575,1578,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1596,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1597,[198,37,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1598,[198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1599,[17,1574]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1600,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1601,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1602,[17,24,85,409,777,857,966,946,880,805,804,1543,1545,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1603,[951,868,867,946]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1604,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1605,[805,779,812,17,368,266,347,363,219,385,278,409,85,1480,1351,880,780,1055,878,876,777,804,1516,891,1606,1514,1515,1470,1352,1527,890,1607,1524,8,260]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1606,[876,816,996]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1607,[831]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1608,[]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1609,[]); -__d(function(o,s,e,p,c,t,d){"use strict";c.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1610,[]); -__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1611,[]); -__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1612,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1613,[13,17,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1614,[1615]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1615,[8,1616,574]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1616,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1617,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1618,[8,482,17,253,634]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHTS_PLAN_LABEL",{enumerable:!0,get:function(){return D}}),_e.useInsightsAccess=S,_e.SuperProInsights=B,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,v.jsx)(n.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,v.jsx)(B,{go:e})}):(0,v.jsx)(_,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.sales)return(0,v.jsx)(_,{});const i=r.sales;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Last 7 days"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=i.last7?(0,x.moneyGbp)(i.last7):'\u2014'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.prev7?`The 7 days before: ${(0,x.moneyGbp)(i.prev7)}${null!=i.changePct?` (${i.changePct>=0?'up':'down'} ${Math.abs(i.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.sph7?`Spend per head ${(0,x.moneyGbp)(i.sph7)}`:'Spend per head shows once days have a cash up and Covers'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Takings by week"}),(0,v.jsx)(R,{values:i.weeks.map(e=>e.gross),w:300,h:70}),i.weeks.slice().reverse().map(e=>(0,v.jsx)(E,{a:`${(0,b.ukDate)(e.from)} \u2013 ${(0,b.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up`:'No signed-off cash ups'},e.to)),(0,v.jsx)(l.Muted,{center:!0,children:"Gross takings from signed-off cash ups only, as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,v.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Spend per head",onPress:()=>e('more','spendhead')})]})]})},_e.InsightsStockPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.stock)return(0,v.jsx)(_,{});const i=r.stock;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Low or out now"}),(0,v.jsx)(l.Muted,{center:!0,children:"Live tracked stock (the counts on the Display, Staff and Head Chef apps), at or below each item\u2019s warn-at level."}),i.low.length?i.low.map(e=>(0,v.jsx)(E,{testID:`low-${e.key}`,tone:e.out?w.colours.red:w.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,v.jsx)(l.Muted,{center:!0,children:i.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:`Price rises in the last ${b.RISE_DAYS} days`}),i.rises.length?i.rises.map(e=>(0,v.jsx)(E,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,y.gbp)(e.before)} \u2192 ${(0,y.gbp)(e.after)} a pack \xb7 ${(0,b.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,v.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,v.jsx)(l.Muted,{center:!0,children:i.lastCount?`Last full stock count ${(0,b.ukDate)(i.lastCount)}.`:'No full stock count yet.'})]}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Deliveries, stock & GP",onPress:()=>e('more','kitchencosts')})]})},_e.InsightsGpPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.gp)return(0,v.jsx)(_,{});const i=r.gp;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,v.jsx)(O,{example:r.example}),r.example?(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:w.colours.gold,children:L(i.menu)}),null!=i.startMenu&&null!=i.menu?(0,v.jsx)(l.Muted,{center:!0,children:`${T(i.menu-i.startMenu)} points since ${(0,b.ukDate)(i.trend[0]?.week??'')}`}):null,(0,v.jsx)(R,{values:i.trend.map(e=>e.menu),w:300,h:80})]}):(0,v.jsx)(j.GpOverTime,{rid:s}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),i.drops.length?i.drops.map(e=>(0,v.jsx)(E,{testID:`drop-${e.dishId}`,tone:w.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,b.ukDate)(e.date)}`},e.dishId)):(0,v.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Each dish over 3 months"}),i.dishes.length?i.dishes.map(e=>(0,v.jsx)(E,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const t=S(),o=P(),{list:r,source:i}=C(),[a,c]=(0,s.useState)('all');if(!t.clock)return(0,v.jsx)(_,{});const d='unsigned'===a?r.filter(e=>!1===e.signed):r,u=e=>{const s=new Date(e);return isNaN(s.getTime())?e:s.toLocaleString('en-GB',{day:'2-digit',month:'2-digit',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,v.jsx)(O,{example:!!o}),(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${r.length})`,onPress:()=>c('all'),testID:"clock-filter-all"}),(0,v.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${r.filter(e=>!1===e.signed).length})`,onPress:()=>c('unsigned'),testID:"clock-filter-unsigned"})]}),(0,v.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:d.length?d.map(e=>(0,v.jsxs)(n.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${b.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,b.ukDate)(e.workDate)}. ${e.before?`Before ${e.before}. `:''}${e.after?`After ${e.after}. `:''}By ${e.by}, ${u(e.at)}.${!1===e.signed?' Not signed off yet.':''}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?w.colours.amber:w.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,b.ukDate)(e.workDate)}`}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,children:`${b.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,v.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,v.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,v.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,v.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${b.CLOCK_DAYS} days.`})}),(0,v.jsx)(l.Muted,{center:!0,children:'server'===i?'From the server\u2019s timesheet audit.':'synced'===i?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),o=_r(_d[3]),r=e(o),l=_r(_d[4]),i=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),$=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]);const D='SuperPro';function S(){const{role:e}=(0,k.useCtx)(6e4),s=(0,k.useSignedIn)(),t=(0,k.useInStaffApp)();return(0,b.insightsAccess)({viewRole:e,signed:s,live:(0,$.isLive)(),inStaffApp:t,perm:e=>(0,$.can)(e)})}function P(){return(0,f.useExamples)()&&!(0,$.isLive)()?I.INSIGHTS_SAMPLE:null}function C(){const e=P(),t=(0,u.useOwner)(e=>e.attendance),n=(0,u.useOwner)(e=>e.staff),[o,r]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(e||!(0,$.isLive)())return;let s=!0;return(0,$.readClockChanges)(b.CLOCK_DAYS).then(e=>{s&&e&&r((0,b.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,s.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const s=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:s(o),source:'server'};const r=(0,b.addDaysYmd)((new Date).toISOString().slice(0,10),-b.CLOCK_DAYS);return{list:s((0,b.clockChangesFromAttendance)(t,r)),source:'synced'}},[e,o,t,n])}function M(e){const t=P(),[n,o]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(t||!e||!(0,$.isLive)())return;let s=!0;return(0,$.readLoyaltyInsight)().then(e=>{s&&o(e?(0,b.loyaltyInsight)(e.raw,e.source):null)}),()=>{s=!1}},[t,e]),t?t.loyalty:e&&(0,$.isLive)()?n:null}function N(e,t){const n=P(),o=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,i.useBookings)(e),f=(0,i.useOrders)(e),y=(0,a.useReviews)(e=>e.reviews),x=(0,u.useOwner)(e=>e.attendance),$=(0,k.useHourly)(),w=(0,d.useGpCalcView)(),j=(0,i.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),v=(0,g.useShellStore)((0,p.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,s.useMemo)(()=>{if(n)return{example:!0,...n};const s=j.map(e=>({id:e.id,dish:e.dish,price:e.price})),i=new Date,a=(0,b.salesInsight)(o,l,e,t),c=x.filter(e=>!e.voided&&'confirmed'===(0,u.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,k.paidMins)(e,i).paid,hourly:$[e.staffId]??0}));return{example:!1,sales:a,stock:(0,b.stockInsight)((I??[]).filter(e=>!e.group),v,(s,t)=>(0,h.fmtStockCount)(e,s,t),w.ingredients,Object.values(w.counts??{}),t),gp:(0,b.gpInsight)(w.ingredients,w.cardCosts??{},s,w.settings,Object.values(w.deliveries??{}),t),bookings:(0,b.bookingsInsight)(l,e,t),orders:(0,b.ordersInsight)(f,e,t),reviews:(0,b.reviewsInsight)(y,e,t),labour:(0,b.labourInsight)(c,a.last7,t),salesReport:(0,b.salesReportInsight)(r,e)}},[n,o,r,l,f,y,x,$,e,t,w,j,I,v])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,T=e=>`${e>0?'+':''}${e.toFixed(1)}`;function R({values:e,w:s=220,h:t=44,testID:l}){const i=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(i.length<2)return null;const a=Math.min(...i.map(e=>e.v)),c=Math.max(...i.map(e=>e.v))-a||1,d=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/c*(t-12),g=i[i.length-1];return(0,v.jsx)(n.default,{testID:l,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,v.jsxs)(r.default,{width:s,height:t,children:[(0,v.jsx)(o.Polyline,{points:i.map(e=>`${d(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:w.colours.gold,strokeWidth:2.5,fill:"none"}),(0,v.jsx)(o.Circle,{cx:d(g.i),cy:u(g.v),r:3.5,fill:w.colours.gold})]})})}function G({title:e,big:s,line:n,tone:o,onPress:r,testID:i,children:a,a11y:c,plan:d}){return(0,v.jsxs)(t.default,{testID:i,accessibilityRole:"button",accessibilityLabel:c,accessibilityHint:"Opens the detail",onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??w.colours.gold,backgroundColor:e?w.colours.goldTint:w.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:e}),d?(0,v.jsx)(l.T,{size:11,weight:"semibold",colour:w.colours.goldLight,center:!0,children:d.toUpperCase()}):null,(0,v.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??w.colours.text,children:s}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.muted,children:n}),a,(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.goldLight,children:"Open \u203a"})]})}function O({example:e}){return(0,v.jsxs)(n.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.T,{size:20,weight:"bold",colour:w.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,v.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,v.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function A({title:e,sub:s,children:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.Badge,{kind:"gold",label:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]}),(0,v.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function B({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t),l=C(),i=M(o.loyalty);if(!o.any)return null;const a=(0,b.clockSummary)(l.list),c=(0,b.loyaltyLine)(i),d=s=>e('more',s),u=r.sales,g=r.stock,h=r.gp,p=r.bookings,f=r.orders,$=r.reviews,j=r.labour,I=r.salesReport,P=e=>b.INSIGHT_PLAN[e],B=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=o.sales||o.stock||o.gp||o.clock,E=o.bookings||o.noshows||o.orders||o.loyalty||o.reviews||o.labour||o.salesReports;return(0,v.jsxs)(n.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,v.jsx)(O,{example:r.example}),_?(0,v.jsxs)(A,{testID:"insights-group-superpro",title:D,sub:"Connected EPOS insights",children:[o.sales?(0,v.jsx)(G,{plan:P('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>d('insights-sales'),big:B(u.last7),line:null==u.last7?'No signed-off cash ups in the last 7 days':"Last 7 days"+(null!=u.changePct?` \xb7 ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)}% on the 7 before`:''),a11y:`Sales and takings. ${null!=u.last7?`Last 7 days ${(0,x.moneyGbp)(u.last7)}`:'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,v.jsx)(R,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,o.stock?(0,v.jsx)(G,{plan:P('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>d('insights-stock'),tone:g.low.length?w.colours.amber:void 0,big:g.low.length?`${g.low.length} low`:g.tracked?'None low':'\u2014',line:`${g.low.length?g.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):g.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${g.rises.length} price rise${1===g.rises.length?'':'s'} in ${b.RISE_DAYS} days`,a11y:`Stock. ${g.low.length} tracked items low or out. ${g.rises.length} price rises in ${b.RISE_DAYS} days`}):null,o.gp?(0,v.jsx)(G,{plan:P('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>d('insights-gp'),tone:h.drops.length?w.colours.amber:void 0,big:L(h.menu),line:null==h.menu?'Cost your recipe cards to see GP':`Menu GP${null!=h.startMenu?` \xb7 ${T(h.menu-h.startMenu)} pts in 3 months`:''} \xb7 ${h.drops.length} dish${1===h.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(h.menu)}. ${h.drops.length} dishes fell after a cost change`,children:(0,v.jsx)(R,{testID:"insight-gp-spark",values:h.trend.map(e=>e.menu)})}):null,o.clock?(0,v.jsx)(G,{plan:P('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>d('insights-clock'),tone:a.unsigned?w.colours.amber:void 0,big:String(a.total),line:`Edits in ${b.CLOCK_DAYS} days \xb7 ${a.unsigned} not signed off yet${a.latest?` \xb7 latest by ${a.latest.by}`:''}`,a11y:`Clock-in changes. ${a.total} edits in ${b.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,v.jsxs)(A,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[o.salesReports?(0,v.jsx)(G,{plan:P('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:B(I.gross),line:I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}${I.top.length?` \xb7 ${I.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}, ${B(I.gross)}`:'None yet')}):null,o.bookings?(0,v.jsx)(G,{plan:P('bookings'),testID:"insight-card-bookings",title:"Bookings & Covers",onPress:()=>e('more','bizinsights'),big:String(p.covers7),line:`Covers, last 7 days \xb7 ${p.coversPrev7} the 7 before${null!=p.walkInPct?` \xb7 ${p.walkInPct}% walk-ins`:''}`,a11y:`Bookings and Covers. ${p.covers7} Covers in the last 7 days, ${p.coversPrev7} the 7 before`}):null,o.noshows?(0,v.jsx)(G,{plan:P('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?w.colours.amber:void 0,big:null!=p.noShowPct?`${p.noShowPct}%`:'\u2014',line:`No-shows, 30 days (${p.noShows30}) \xb7 deposits asked ${p.deposits30.asked}, paid ${p.deposits30.paid}${o.sales?` (${(0,y.gbp)(p.deposits30.paidPence)})`:''}${p.deposits30.waived?`, let off ${p.deposits30.waived}`:''}`,a11y:`No-shows and deposits. No-show rate ${p.noShowPct??'not known'} percent over 30 days. ${p.deposits30.paid} of ${p.deposits30.asked} deposits paid`}):null,o.orders?(0,v.jsx)(G,{plan:P('orders'),testID:"insight-card-orders",title:"Orders & takeaway",onPress:()=>e('more','orders'),big:String(f.count7),line:`Orders, last 7 days \xb7 ${f.takeaway7} takeaway, ${f.table7} table \xb7 ${(0,y.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,o.reviews?(0,v.jsx)(G,{plan:P('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:$.low30?w.colours.amber:void 0,big:null!=$.avg30?`${$.avg30.toFixed(1)} \u2605`:'\u2014',line:`${$.count30} review${1===$.count30?'':'s'} in 30 days \xb7 ${$.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${$.avg30??'none'} stars from ${$.count30} reviews in 30 days`}):null,o.loyalty?(0,v.jsx)(G,{plan:P('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:c.big,line:c.line,a11y:`Loyalty. ${i?.members??'Not known'} members. ${i?.stampsMonth??'Not known'} stamps this month. ${i?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,o.labour?(0,v.jsx)(G,{plan:P('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=j.pct7&&j.pct7>35?w.colours.amber:void 0,big:null!=j.pct7?`${j.pct7}%`:'\u2014',line:`Wages of takings, last 7 days \xb7 ${j.paidHours7} signed-off hours${null!=j.labour7?` \xb7 ${B(j.labour7)}`:''}`,a11y:`Wages and hours versus takings. ${j.pct7??'Not known'} percent over 7 days, ${j.paidHours7} hours`}):null]}):null]})}function _(){return(0,v.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function E({a:e,b:s,tone:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]})}},1455,[17,385,85,780,777,858,1233,1006,951,876,942,944,864,1142,851,1456,1458,946,804,1055,1174,1459,8]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1456,[839,1457]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1457,[839]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHT_KEYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"INSIGHT_PLAN",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isHeadChef",{enumerable:!0,get:function(){return a}}),_e.insightsAccess=function(e){if(e.inStaffApp||'owner'!==e.viewRole)return s;if(e.signed){if(a(e.signed))return s;if('owner'!==e.signed.role&&!0!==e.signed.ownerAccess)return s}else if(e.live)return s;const t=t=>!e.live||e.perm(t),n=t('takings.view'),o={sales:n,salesReports:n,gp:n,orders:n,labour:n&&t('wages.view'),stock:t('stock.manage'),clock:t('rota.manage')||t('attendance.view'),bookings:!0,noshows:!0,loyalty:!0,reviews:!0};return{...o,any:r.some(e=>o[e])}},Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return l}}),_e.addDaysYmd=c,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return d}}),_e.salesInsight=function(e,t,r,o){const s={from:c(o,-6),to:o},a={from:c(o,-13),to:c(o,-7)},i=(0,n.takingsInRange)(e,r,s),l=(0,n.takingsInRange)(e,r,a),d=(0,n.spendPerHeadInRange)(e,t,r,s).sph,u=[];for(let t=7;t>=0;t--){const s=c(o,-7*t),a=c(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});u.push({from:a,to:s,gross:i.gross,days:i.days})}const f=null!=i.gross&&null!=l.gross&&l.gross>0?Math.round((i.gross-l.gross)/l.gross*1e3)/10:null;return{last7:i.gross,prev7:l.gross,changePct:f,days7:i.days,sph7:d,weeks:u,empty:u.every(e=>null==e.gross)}},Object.defineProperty(_e,"RISE_DAYS",{enumerable:!0,get:function(){return u}}),_e.stockInsight=function(e,t,n,r,o,s){const a=e.filter(e=>e.active),i=a.map(e=>({i:e,n:t[e.key]??0})).filter(({i:e,n:t})=>t<=e.lowAt).map(({i:e,n:t})=>({key:e.key,name:e.plural||e.name,count:t,lowAt:e.lowAt,out:t<=0,countText:n(e,t),lowText:n(e,e.lowAt)})).sort((e,t)=>e.out===t.out?e.count/Math.max(1,e.lowAt)-t.count/Math.max(1,t.lowAt):e.out?-1:1),l=c(s,-30),d=[];for(const e of r){const t=[...e.prices??[]].filter(e=>e.at).sort((e,t)=>e.at.localeCompare(t.at));if(t.length<2)continue;const n=t[t.length-2],r=t[t.length-1];r.p>n.p&&n.p>0&&r.at.slice(0,10)>=l&&d.push({ingId:e.id,name:e.name,before:n.p,after:r.p,pct:Math.round((r.p-n.p)/n.p*1e3)/10,at:r.at.slice(0,10),supplier:e.supplier})}d.sort((e,t)=>t.pct-e.pct);const u=[...o].sort((e,t)=>t.date.localeCompare(e.date))[0];return{low:i,tracked:a.length,rises:d,lastCount:u?.date??null,empty:!a.length&&!d.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),_e.gpInsight=function(n,r,o,s,a,i){const l=(0,e.menuGp)(n,r,o,s),d=(0,e.gpHistory)(a,l,'3m',i),u=d.points.find(e=>null!=e.menu)?.menu??null,f=l.dishes.map(e=>{const t=d.points.find(t=>null!=t.dishes[e.id])?.dishes[e.id];return{id:e.id,name:e.name,gp:e.gp,target:e.target,change:null!=t?Math.round(10*(e.gp-t))/10:null}}).sort((e,t)=>(e.change??0)-(t.change??0)),g=(0,t.marginDrops)(a,c(i,-14)).filter(e=>o.some(t=>t.id===e.dishId)).map(e=>({dishId:e.dishId,dish:e.dish,before:e.before,after:e.after,drop:Math.round(10*e.drop)/10,date:e.date,supplier:e.supplier}));return{menu:l.menu,startMenu:u,trend:d.points.map(e=>({week:e.week,menu:e.menu})),dishes:f,drops:g,underTarget:l.dishes.filter(e=>e.gp=t&&n.push({id:`${r.id}:reclock`,attendanceId:r.id,staffRef:r.staffId,workDate:r.date,kind:'reclock',after:r.in?m(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return k(n)},_e.clockChangesFromServer=function(e){return k(e.filter(e=>p.has(e.action)||'deleted'===e.action||'reclock'===e.action).map(e=>({id:String(e.id),attendanceId:String(e.attendance_id),staffRef:String(e.staff_ref),staffName:e.staff_name??void 0,workDate:String(e.work_date).slice(0,10),kind:e.action,before:h(e.action,e.old_value),after:h(e.action,e.new_value),by:e.changed_by_name,at:String(e.changed_at),reason:e.reason??void 0,signed:'deleted'===e.action?null:e.signed??null})))},_e.clockSummary=function(e){return{total:e.length,unsigned:e.filter(e=>!1===e.signed).length,people:new Set(e.map(e=>e.staffRef)).size,editors:new Set(e.map(e=>e.by)).size,latest:e[0]??null}},Object.defineProperty(_e,"CLOCK_DAYS",{enumerable:!0,get:function(){return b}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:c(r,-6),to:r},a={from:c(r,-13),to:c(r,-7)},i={from:c(r,-29),to:r},l=(0,n.coversInRange)(o,s),d=(0,n.coversInRange)(o,a),u=(0,n.noShowRate)(o,i,t),f=(0,n.cancelRate)(o,i,t),g=o.filter(e=>{const t=e;return'deposit'===t.security&&!!t.date&&t.date>=i.from&&t.date<=i.to});return{covers7:l.total,coversPrev7:d.total,walkInPct:l.walkInPct,noShowPct:u.rate,noShows30:u.count,cancelPct:f.rate,deposits30:{asked:g.length,paid:g.filter(e=>(e.depositPaid??0)>0).length,paidPence:g.reduce((e,t)=>e+(t.depositPaid??0),0),waived:g.filter(e=>!!e.depositWaived).length}}},_e.ordersInsight=function(e,t,n){const r=c(n,-6),o=e.filter(e=>(!e.restaurantId||e.restaurantId===t)&&e.createdAt&&e.createdAt.slice(0,10)>=r&&e.createdAt.slice(0,10)<=n&&'cancelled'!==e.status);return{count7:o.length,takeaway7:o.filter(e=>'takeaway'===e.type).length,table7:o.filter(e=>'table'===e.type).length,valuePence7:o.reduce((e,t)=>e+(t.subtotal||0),0)}},_e.reviewsInsight=function(e,t,r){const o=e.filter(e=>!e.restaurantId||e.restaurantId===t),s={from:c(r,-29),to:r},a=(0,n.reviewAverage)(o,s);return{avg30:a.avg,count30:a.count,low30:o.filter(e=>e.createdAt.slice(0,10)>=s.from&&e.rating<=2).length}},_e.labourInsight=function(e,t,r){const o={from:c(r,-6),to:r},s=(0,n.labourCostInRange)(e,o),a=e.filter(e=>e.date>=o.from&&e.date<=o.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:s,takings7:t,pct7:(0,n.labourPctOfTakings)(s,t),paidHours7:Math.round(a/6)/10}},_e.salesReportInsight=function(e,t){const n=e.filter(e=>e.rid===t&&e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0];if(!n)return{weekStart:null,gross:null,top:[]};const r='number'==typeof n.vals.gross?n.vals.gross:null;return{weekStart:n.weekStart,gross:r,top:[...n.categories].sort((e,t)=>t.amount-e.amount).slice(0,3)}},_e.loyaltyInsight=function(e,t){if(!e||'object'!=typeof e)return null;const n=w(e.members),r=w(e.stampsMonth),o=w(e.rewardsUsedMonth??e.rewardsMonth),s=w(e.stampsLastMonthToDate??e.stampsLastMonth);if(null==n&&null==r&&null==o)return null;const a=null!=r&&null!=s&&s>0?Math.round((r-s)/s*1e3)/10:null;return{members:n,stampsMonth:r,stampsLastMonth:s,stampsChangePct:a,rewardsMonth:o,source:t}},_e.loyaltyLine=function(e){const t=e=>null==e?'\u2014':String(e);if(!e)return{big:'\u2014',line:'Members \xb7 stamps this month \u2014 \xb7 rewards redeemed this month \u2014'};const n=null==e.stampsLastMonth?'':` (${t(e.stampsLastMonth)} by this date last month${null==e.stampsChangePct?'':`, ${e.stampsChangePct>0?'up':e.stampsChangePct<0?'down':'level'}${e.stampsChangePct?` ${Math.abs(e.stampsChangePct)}%`:''}`})`;return{big:t(e.members),line:`Members \xb7 stamps this month ${t(e.stampsMonth)}${n} \xb7 rewards redeemed this month ${t(e.rewardsMonth)}`}};var e=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]);const r=['sales','salesReports','gp','stock','clock','bookings','noshows','orders','loyalty','reviews','labour'],o={sales:'SuperPro',gp:'SuperPro',stock:'SuperPro',clock:'SuperPro',salesReports:'Pro',bookings:'Pro',noshows:'Pro',orders:'Pro',loyalty:'Pro',reviews:'Pro',labour:'Pro'},s=Object.fromEntries([...r.map(e=>[e,!1]),['any',!1]]),a=e=>/head chef/i.test(e.level??'')||/head chef/i.test(e.job??'');const i=e=>String(e).padStart(2,'0'),l=e=>`${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}`;function c(e,t){const[n,r,o]=e.split('-').map(Number),s=new Date(n,r-1,o);return s.setDate(s.getDate()+t),l(s)}const d=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14;const g={clock_in:'Clock-in changed',clock_out:'Clock-out changed',break:'Break changed',added:'Shift added by hand',voided:'Shift removed from hours',unvoided:'Shift put back in hours',deleted:'Shift deleted',reopened:'Signed-off shift reopened',reclock:'Clocked in again after clocking out',request_applied:'Correction request applied'},p=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),m=e=>{const t=new Date(e);if(isNaN(t.getTime()))return e;try{return t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return`${i(t.getHours())}:${i(t.getMinutes())}`}};function h(e,t){if(null!=t&&''!==t)return'clock_in'!==e&&'clock_out'!==e||!/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(t)?'break'===e&&/^\d+$/.test(t)?`${t} min break`:t:m(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const k=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const b=30;const w=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1458,[954,952,1456]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INSIGHTS_SAMPLE",{enumerable:!0,get:function(){return t}});const t=null},1459,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1460,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1461,804,856,1055,1462,1465,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1461,[1032]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1462,[812,17,362,385,278,85,777,1463,1464,804,1460,1055,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1463,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1464,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1465,[17,385,85,777,860,1464,996,842,1466,1461,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1466,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1467,[813,17,266,347,219,385,85,831,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1468,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1469,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1470,[831]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1471,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1472,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1472,[17,85,777,858,851,946,804,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return ye}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),G=_r(d[22]),M=_r(d[23]),O=_r(d[24]),I=_r(d[25]),B=_r(d[26]),E=_r(d[27]),x=_r(d[28]),D=_r(d[29]),L=_r(d[30]),N=(e=L)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),ge=_r(d[59]),pe=_r(d[60]),he=_r(d[61]),be=_r(d[62]),fe=_r(d[63]);const ye=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},Ce=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:Ce,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>Ce(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:Ce,C:I.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:Ce,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>Ce(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:Ce,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:Ce,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:Ce,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:Ce,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:Ce,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:Ce,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:Ce,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:Ce,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:Ce,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:Ce,C:R.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:Ce,C:A.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:Ce,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:Ce,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:Ce,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:Ce,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:Ce,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:Ce,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:Ce,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:D.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>ye(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:Ce,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:Ce,C:D.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:D.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:Ce,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:Ce,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:Ce,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:Ce,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>N.default.createElement(H.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:_.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:H.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:Q.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:Ce,C:q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:Ce,C:q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:Ce,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:Ce,C:F.DisplaySettingsPage}]);const Se=e=>'owner'===e||'manager'===e;V.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Se,C:V.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Se,C:V.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:U.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:Y.AssistantsPage}]);const ke=e=>'owner'===e||'manager'===e,ve=e=>'owner'===e;(0,y.register)([{id:'superpro-insights',title:'Insights',sub:'Every owner metric in one place: sales, stock, GP, clock-in changes, bookings, orders, reviews, loyalty and wages',group:'Run the day',can:ve,C:G.SuperProInsightsPage},{id:'insights-sales',title:'Insights: Sales',sub:'SuperPro \xb7 takings by week, last 7 days against the 7 before, spend per head',group:'Run the day',can:ve,C:G.InsightsSalesPage},{id:'insights-stock',title:'Insights: Stock',sub:'SuperPro \xb7 low at the last count (par levels) and recent price rises',group:'Run the day',can:ve,C:G.InsightsStockPage},{id:'insights-gp',title:'Insights: GP',sub:'SuperPro \xb7 menu and dish GP over time, and dishes whose GP fell after a cost change',group:'Run the day',can:ve,C:G.InsightsGpPage},{id:'insights-clock',title:'Insights: Clock-in changes',sub:'SuperPro \xb7 who edited which shift, when, before and after, and edits not signed off',group:'Run the day',can:ve,C:G.InsightsClockPage}]);const we=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Pe=e=>ke(e)&&we();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ke,C:W.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Pe,C:W.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Pe,C:W.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Pe,C:W.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:ke,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ke,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:W.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:Ce,C:j.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:Ce,C:j.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:Ce,C:j.Outbox}]);const Re=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:Re,C:$.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:$.optinsAllowed,C:$.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Re,C:K.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Re,C:z.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Re,C:J.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Re,C:X.OrderSheetSettings},...Z.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Re,C:(0,z.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Re,C:ee.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Re,C:te.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:Ce,C:te.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Re,C:te.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Re,C:se.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:Ce,C:ae.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:Ce,C:ae.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:Ce,C:ae.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:Ce,C:ie.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:Ce,C:re.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:Ce,C:ne.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:Ce,C:ue.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ue.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(le.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(de.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ke,C:function(){const{rid:e,today:t}=(0,ce.useCtx)(6e4);return N.default.createElement(de.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(ge.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:Ce,C:oe.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:Ce,C:he.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:Ce,C:be.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:fe.UseOnComputerPage}])},1473,[822,1048,856,1474,876,966,955,816,866,1476,1483,1491,1446,1492,1493,1495,1496,1155,1469,1497,1498,1499,1455,1196,1187,1471,1500,1444,1501,1502,17,1193,1176,1445,1433,1447,1485,1507,1508,1454,1509,1436,1421,1510,1451,1511,886,1512,1513,1515,1182,1460,1516,1382,1462,1528,1079,1055,1197,1149,1531,1534,1537,1540]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1474,[17,378,219,385,85,19,777,1024,1327,876,804,1475,1184,1470,1055,8,260]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1475,[831]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1476,[812,1442,17,851,85,777,876,804,1055,884,885,1477,946,962,1029,1440,1478,1479,1481,994,1482,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1477,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1478,[812,17,85,777,804,876,1343,1342,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1479,[17,85,777,1480,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1480,[831,892,946,880]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1481,[17,85,777,804,960,1020,946,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1482,[892,946]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1483,[17,85,777,835,876,1484,804,1055,1485,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1484,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1485,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1486,1490,804,1055,1069,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1486,[1487,1489,1488]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1487,[843,1488]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1488,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1489,[1487,891]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1490,[869,824,831,834]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1491,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1492,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1493,[1037,17,85,1494,814,857,777,876,804,1055,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1494,[812,17,219,385,85,780,814,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1495,[17,1151,847,1055,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1496,[17,1030,1055,946,961,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1497,[17,1388,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1498,[17,85,780,777,858,1006,1457,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1499,[17,85,1336,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1500,[17,776,1055,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1501,[17,85,777,858,1006,876,1053,1456,946,804,1232,1233,1055,8]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1502,[805,1408,812,822,843,1503,1427,1475,1218,841,1254,946,1504,1506,1428,17,1096,1483,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1503,[843,17,85,777,845,851,1150,858,853,804,8]); +__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1504,[946,17,264,219,85,1272,777,1251,1254,804,1505,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1505,[17,219,85,777,1251,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1506,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1507,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1508,[17,85,777,946,863,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1509,[813,812,822,17,219,385,85,777,1220,858,1490,848,1222,1016,804,1025,1055,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1510,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1511,[17,385,85,777,876,998,851,999,804,840,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1512,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1513,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1514,804,880,1157,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1514,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1515,[17,85,777,804,1423,1503,1055,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1516,[812,1031,779,17,385,85,777,876,1467,1517,1518,1519,804,1055,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1517,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1518,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1519,[1520,1098,843,1521,1522,876,858,996,1467,1517,1518,1524,1523,1526,1527,994,995]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1520,[1062,1061,1021]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1521,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1522,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1523,1521]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1523,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1524,1525]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1524,[824,831,834]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1525,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1526,[816,876,956,851,1523,1015,1069]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1527,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1528,[17,362,85,777,804,1463,1524,1475,1525,1352,890,1529,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1529,[17,85,777,804,1530,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1530,[824,831,834]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1531,[17,779,85,777,845,1251,1532,1533,804,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1532,[845]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1533,[946,1532,1254]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1534,[17,85,777,858,1006,1535,938,839,1536,1018,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1535,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1536,[839,1007,1457]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1537,[812,17,85,777,1538,1019,804,1539,1055,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1538,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1539,[1018,1019,935,892,946]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1540,[17,264,219,85,777,812,804,946,1418,1182,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1541,[219]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1543,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1544,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1467,1084,1082,1222,1235,938,876,1030,1475,880,946,804,1327,1545,1055,1485,1407,1155,1469,1471,1460,1446,1473,1541,1543,1551,1552,1553,1556,1559,8]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1545,[17,266,347,219,385,278,85,409,780,779,1327,1446,1473,1407,1155,1471,1469,1055,1024,777,858,876,863,946,880,804,1546,1547,1548,1549,1550,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1546,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1547,[17,780,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1548,[17,85,777,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1549,[17,385,1157,1158,816,805,777,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1550,[17,219]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=h,e.buttonsFor=function(s){return o.filter(t=>h(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),h=Math.floor(Math.max(88,(t-72-64-36)/i)),c=t>=1e3?15:13,k=Math.round(1.4*c),b=Math.max(48,Math.min(72,h-2*k-14,l-34));return{panelW:n,colW:l,per:h,circle:b,label:c,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return c}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}],last:[{id:'superpro-insights',label:'Insights',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function h(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const c=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1551,[1546]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1552,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1553,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1554,1543,1552,1555,8]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1554,[17,385,278,85,777,804,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1555,[17,85,780,777,804,1554,1552,8]); +__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1556,[17,264,385,85,780,777,858,876,1557,961,1208,1453,804,1547,1055,1554,1558,1552,1555,1553,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1557,[831,834,824]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1558,[961]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1559,[17,85,777,804,1560,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1560,[]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1561,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1467,1085,1084,1082,1475,1222,880,804,1485,1407,1155,1055,1420,1469,1460,1471,1446,1473,1562,1541,1564,1566,1568,1565,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1562,[17,278,85,1494,857,777,876,814,1447,804,1563,1564,1565,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1563,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1564,[17]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1565,[17,85,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1566,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1563,1564,1565,1567,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1567,[876]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1568,[17,85,777,876,1058,804,1563,1564,1565,1049,1567,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1569,[13,17,856,1570,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1570,[1447,1571,813,958,1070,1503,1202,1203,1026,1023,1024,1504,1531,1506,1149,938,979,1572,976,880,1029,1030,1481,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1497,1492,1513,1573,1415,966,219,1237,1176,1182,1445,1196,1193,1468,1179,878,1205,1206,884,776,946,8]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1571,[17,85,777,1055,946,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1572,[219,977]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1573,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1574,[13,17,856,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1575,[1440,946,778,1401,1576,993,13,1603,479,17,368,319,219,24,85,805,857,1063,856,1605,19,858,996,876,804,1415,966,987,1606,1607,1026,1608,1102,880,1006,960,1611,1372,8,1612,1613,1614,1615]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1576,[1577,1600,1602]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1577,[198,1578,1581,1595,1596,1597,1598,1599]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1578,[198,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1579,[1580]); +__d(function(g,r,i,a,m,e,d){},1580,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1581,[1582,198,1578,1595,1596]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1582,[1583,1584,1594]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1583,[1584,1588,1593]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1584,[198,355,1585,1589,1590,1591,1592,1588,1593]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1585,[198,1586,322,263,1587,1588]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1586,[487]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1587,[198,322]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1588,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1589,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1590,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1591,[1589]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1592,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1593,[355,1587]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1594,[17,1584]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1595,[1582,198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1596,[1582,1595]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1597,[1578]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1598,[198,1578,1581,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1599,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1600,[198,37,1601]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1601,[198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1602,[17,1577]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1603,[1604]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1604,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1605,[17,24,85,409,777,857,966,946,880,805,804,1546,1548,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1606,[951,868,867,946]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1607,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1608,[805,779,812,17,368,266,347,363,219,385,278,409,85,1485,1351,880,780,1055,878,876,777,804,1519,891,1609,1517,1518,1475,1352,1530,890,1610,1527,8,260]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1609,[876,816,996]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1610,[831]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1611,[]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1612,[]); +__d(function(o,s,e,p,c,t,d){"use strict";c.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1613,[]); +__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1614,[]); +__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1615,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1616,[13,17,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1617,[1618]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1618,[8,1619,574]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1619,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1620,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1621,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/car-app/index.html b/car-app/index.html index 188d26069d9101291110355657c44708cd079cb8..4dc6f5662a21ef291881d3f05bb45f5fa7b4dcfc 100644 --- a/car-app/index.html +++ b/car-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/car-app/owner.html b/car-app/owner.html index dca048c2ebe12f40687bcc00877f0d50cbd474db..70363866d8b903fd788522ef38c842226b02813f 100644 --- a/car-app/owner.html +++ b/car-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/car-app/sw.js b/car-app/sw.js index 56df4d45f7456f918b54fd698ced4c6c94046c18..047201661c0320ec7d8c1cc4e45fc25db49433ff 100644 --- a/car-app/sw.js +++ b/car-app/sw.js @@ -1,7 +1,7 @@ // Anchorage car screen service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-car-76609aa44a"; +const V = "cc-car-773686ea1d"; const BASE = "/car-app/"; -const PRECACHE = ["/car-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/car-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/car-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/car-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/car-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/car-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/car-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/car-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/car-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/car-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/car-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/car-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/car-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/car-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/car-app/favicon.ico", "/car-app/index.html", "/car-app/_expo/static/js/web/bundle.js?v=76609aa44a0ce6eedf80ff4c2e5d0cf64876d2cb22a56e5938cd63c74e257684"]; +const PRECACHE = ["/car-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/car-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/car-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/car-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/car-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/car-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/car-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/car-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/car-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/car-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/car-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/car-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/car-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/car-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/car-app/favicon.ico", "/car-app/index.html", "/car-app/_expo/static/js/web/bundle.js?v=773686ea1d1b3cf0155452342c04e9af9852050b20c8e0fe43eb7b7573918a58"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/chef-app/_expo/static/js/web/bundle.js b/chef-app/_expo/static/js/web/bundle.js index 696a196a8ea825345a0d740e54aa3de73d9ee215..366a0a3ef671c687e8910027dea4a46fea5dc12f 100644 --- a/chef-app/_expo/static/js/web/bundle.js +++ b/chef-app/_expo/static/js/web/bundle.js @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); diff --git a/chef-app/admin.html b/chef-app/admin.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/admin.html +++ b/chef-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer.html b/chef-app/customer.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer.html +++ b/chef-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage.html b/chef-app/customer/anchorage.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage.html +++ b/chef-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/book.html b/chef-app/customer/anchorage/book.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/book.html +++ b/chef-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/feedback.html b/chef-app/customer/anchorage/feedback.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/feedback.html +++ b/chef-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/gift.html b/chef-app/customer/anchorage/gift.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/gift.html +++ b/chef-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/lost.html b/chef-app/customer/anchorage/lost.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/lost.html +++ b/chef-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/loyalty.html b/chef-app/customer/anchorage/loyalty.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/loyalty.html +++ b/chef-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/merch.html b/chef-app/customer/anchorage/merch.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/merch.html +++ b/chef-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/offers.html b/chef-app/customer/anchorage/offers.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/offers.html +++ b/chef-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/refer.html b/chef-app/customer/anchorage/refer.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/refer.html +++ b/chef-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/waitlist.html b/chef-app/customer/anchorage/waitlist.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/waitlist.html +++ b/chef-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/whatson.html b/chef-app/customer/anchorage/whatson.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/anchorage/whatson.html +++ b/chef-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/basket.html b/chef-app/customer/basket.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/basket.html +++ b/chef-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/profile.html b/chef-app/customer/profile.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/customer/profile.html +++ b/chef-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/demo.html b/chef-app/demo.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/demo.html +++ b/chef-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/display.html b/chef-app/display.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/display.html +++ b/chef-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/index.html b/chef-app/index.html index 1c41cbbfb13af8e31393eaff47784fe92c5d308e..7206105cf87daf81480e3b0aeaf303788682d44c 100644 --- a/chef-app/index.html +++ b/chef-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/kitchen.html b/chef-app/kitchen.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/kitchen.html +++ b/chef-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/owner.html b/chef-app/owner.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/owner.html +++ b/chef-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/staff.html b/chef-app/staff.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/staff.html +++ b/chef-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/sw.js b/chef-app/sw.js index 36436f515da4fff8f142566c1e77243247000219..46fc999c4516fcf7f351c88d959472715319f44b 100644 --- a/chef-app/sw.js +++ b/chef-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Head Chef service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-chef-e0b48db09b"; +const V = "cc-chef-32055da8bd"; const BASE = "/chef-app/"; -const PRECACHE = ["/chef-app/apple-touch-icon.png", "/chef-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/chef-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/chef-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/chef-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/chef-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/chef-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/chef-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/chef-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/chef-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/chef-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/chef-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/chef-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/chef-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/chef-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/chef-app/brand-logo.png", "/chef-app/favicon.ico", "/chef-app/icon-192.png", "/chef-app/icon-512.png", "/chef-app/icon-maskable-192.png", "/chef-app/icon-maskable-512.png", "/chef-app/manifest.webmanifest", "/chef-app/index.html", "/chef-app/_expo/static/js/web/bundle.js?v=e0b48db09b237a0742dadd08507d6ed674b1f14a1e5c01b4e9121b2afc714fa3"]; +const PRECACHE = ["/chef-app/apple-touch-icon.png", "/chef-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/chef-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/chef-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/chef-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/chef-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/chef-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/chef-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/chef-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/chef-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/chef-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/chef-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/chef-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/chef-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/chef-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/chef-app/brand-logo.png", "/chef-app/favicon.ico", "/chef-app/icon-192.png", "/chef-app/icon-512.png", "/chef-app/icon-maskable-192.png", "/chef-app/icon-maskable-512.png", "/chef-app/manifest.webmanifest", "/chef-app/index.html", "/chef-app/_expo/static/js/web/bundle.js?v=32055da8bdcae6399c2b060b4f1b80e09d448528a987bd433a4ef2507a9c37cd"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/chef-app/team.html b/chef-app/team.html index 691c08324c3ed097e9271c2a879e3f6b323bb743..70ee98ea20a6b53a150f276268e6304245656e41 100644 --- a/chef-app/team.html +++ b/chef-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/_expo/static/js/web/bundle.js b/customer-app/_expo/static/js/web/bundle.js index da93b1f352ede38ec8eac47b1a08b38cd067ff7c..5a3163ad11df7055395bad43185b1b9fb7bccd07 100644 --- a/customer-app/_expo/static/js/web/bundle.js +++ b/customer-app/_expo/static/js/web/bundle.js @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); diff --git a/customer-app/admin.html b/customer-app/admin.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/admin.html +++ b/customer-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer.html b/customer-app/customer.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer.html +++ b/customer-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage.html b/customer-app/customer/anchorage.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage.html +++ b/customer-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/book.html b/customer-app/customer/anchorage/book.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/book.html +++ b/customer-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/feedback.html b/customer-app/customer/anchorage/feedback.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/feedback.html +++ b/customer-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/gift.html b/customer-app/customer/anchorage/gift.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/gift.html +++ b/customer-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/lost.html b/customer-app/customer/anchorage/lost.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/lost.html +++ b/customer-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/loyalty.html b/customer-app/customer/anchorage/loyalty.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/loyalty.html +++ b/customer-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/merch.html b/customer-app/customer/anchorage/merch.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/merch.html +++ b/customer-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/offers.html b/customer-app/customer/anchorage/offers.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/offers.html +++ b/customer-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/refer.html b/customer-app/customer/anchorage/refer.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/refer.html +++ b/customer-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/waitlist.html b/customer-app/customer/anchorage/waitlist.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/waitlist.html +++ b/customer-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/whatson.html b/customer-app/customer/anchorage/whatson.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/anchorage/whatson.html +++ b/customer-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/basket.html b/customer-app/customer/basket.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/basket.html +++ b/customer-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/profile.html b/customer-app/customer/profile.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/customer/profile.html +++ b/customer-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/demo.html b/customer-app/demo.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/demo.html +++ b/customer-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/display.html b/customer-app/display.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/display.html +++ b/customer-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/index.html b/customer-app/index.html index d5dcef95de3b2b70af9ff54b2860741243c3b8a6..cb6f9545dc16cf9dd1e9e011eeb7b705953694a9 100644 --- a/customer-app/index.html +++ b/customer-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/kitchen.html b/customer-app/kitchen.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/kitchen.html +++ b/customer-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/owner.html b/customer-app/owner.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/owner.html +++ b/customer-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/staff.html b/customer-app/staff.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/staff.html +++ b/customer-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/sw.js b/customer-app/sw.js index 486c9f610cc61a79a672de8de4b2b09e5ddcfc2a..25061e4f1de8520d76cfa6fa95a45a26ff4e9474 100644 --- a/customer-app/sw.js +++ b/customer-app/sw.js @@ -1,7 +1,7 @@ // Anchorage service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-customer-64569f6686"; +const V = "cc-customer-46ca4348bc"; const BASE = "/customer-app/"; -const PRECACHE = ["/customer-app/apple-touch-icon.png", "/customer-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/customer-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/customer-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/customer-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/customer-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/customer-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/customer-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/customer-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/customer-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/customer-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/customer-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/customer-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/customer-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/customer-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/customer-app/brand-logo.png", "/customer-app/favicon.ico", "/customer-app/icon-192.png", "/customer-app/icon-512.png", "/customer-app/icon-maskable-192.png", "/customer-app/icon-maskable-512.png", "/customer-app/manifest.webmanifest", "/customer-app/index.html", "/customer-app/_expo/static/js/web/bundle.js?v=64569f66860fe4def3c476124a49c96ec6429febeddd129586ed7df3d25edd3e"]; +const PRECACHE = ["/customer-app/apple-touch-icon.png", "/customer-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/customer-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/customer-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/customer-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/customer-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/customer-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/customer-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/customer-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/customer-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/customer-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/customer-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/customer-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/customer-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/customer-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/customer-app/brand-logo.png", "/customer-app/favicon.ico", "/customer-app/icon-192.png", "/customer-app/icon-512.png", "/customer-app/icon-maskable-192.png", "/customer-app/icon-maskable-512.png", "/customer-app/manifest.webmanifest", "/customer-app/index.html", "/customer-app/_expo/static/js/web/bundle.js?v=46ca4348bc498db0dfabc8c517d1b9eba353cb0dc40c95cfd692fe5d41822c87"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/customer-app/team.html b/customer-app/team.html index ac8f07698086e5f7c5b8a7e78523b814ca9df431..013ea8905a0cb568820342e063bed3589b4f03e3 100644 --- a/customer-app/team.html +++ b/customer-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/_expo/static/js/web/bundle.js b/display-app/_expo/static/js/web/bundle.js index 2459abc788f84cd59710ba5157c042f33d902207..d7b77f5aa42e7eefbe3bf148383ffa89c384526a 100644 --- a/display-app/_expo/static/js/web/bundle.js +++ b/display-app/_expo/static/js/web/bundle.js @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); diff --git a/display-app/admin.html b/display-app/admin.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/admin.html +++ b/display-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer.html b/display-app/customer.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer.html +++ b/display-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage.html b/display-app/customer/anchorage.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage.html +++ b/display-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/book.html b/display-app/customer/anchorage/book.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/book.html +++ b/display-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/feedback.html b/display-app/customer/anchorage/feedback.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/feedback.html +++ b/display-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/gift.html b/display-app/customer/anchorage/gift.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/gift.html +++ b/display-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/lost.html b/display-app/customer/anchorage/lost.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/lost.html +++ b/display-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/loyalty.html b/display-app/customer/anchorage/loyalty.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/loyalty.html +++ b/display-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/merch.html b/display-app/customer/anchorage/merch.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/merch.html +++ b/display-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/offers.html b/display-app/customer/anchorage/offers.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/offers.html +++ b/display-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/refer.html b/display-app/customer/anchorage/refer.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/refer.html +++ b/display-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/waitlist.html b/display-app/customer/anchorage/waitlist.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/waitlist.html +++ b/display-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/whatson.html b/display-app/customer/anchorage/whatson.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/anchorage/whatson.html +++ b/display-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/basket.html b/display-app/customer/basket.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/basket.html +++ b/display-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/profile.html b/display-app/customer/profile.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/customer/profile.html +++ b/display-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/demo.html b/display-app/demo.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/demo.html +++ b/display-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/display.html b/display-app/display.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/display.html +++ b/display-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/index.html b/display-app/index.html index 81043a48b3727746cfe9dc2b197ddba6fa5bfc85..02cc1fd73d82f2c2bc96a033a8b7a018b3b42af1 100644 --- a/display-app/index.html +++ b/display-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/kitchen.html b/display-app/kitchen.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/kitchen.html +++ b/display-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/owner.html b/display-app/owner.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/owner.html +++ b/display-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/staff.html b/display-app/staff.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/staff.html +++ b/display-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/sw.js b/display-app/sw.js index 2c02ae073c1b2a54337ca57ad2ada67418546518..2b339c618aa3da43262346230d93b288bedd832f 100644 --- a/display-app/sw.js +++ b/display-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Display service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-display-a68ba1b1a0"; +const V = "cc-display-bf75c48f57"; const BASE = "/display-app/"; -const PRECACHE = ["/display-app/apple-touch-icon.png", "/display-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/display-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/display-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/display-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/display-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/display-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/display-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/display-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/display-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/display-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/display-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/display-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/display-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/display-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/display-app/brand-logo.png", "/display-app/favicon.ico", "/display-app/icon-192.png", "/display-app/icon-512.png", "/display-app/icon-maskable-192.png", "/display-app/icon-maskable-512.png", "/display-app/manifest.webmanifest", "/display-app/index.html", "/display-app/_expo/static/js/web/bundle.js?v=a68ba1b1a0dc0d7643f5f4f9956cc12b22ef479948fd074ed69eead89bddc52e"]; +const PRECACHE = ["/display-app/apple-touch-icon.png", "/display-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/display-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/display-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/display-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/display-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/display-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/display-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/display-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/display-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/display-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/display-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/display-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/display-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/display-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/display-app/brand-logo.png", "/display-app/favicon.ico", "/display-app/icon-192.png", "/display-app/icon-512.png", "/display-app/icon-maskable-192.png", "/display-app/icon-maskable-512.png", "/display-app/manifest.webmanifest", "/display-app/index.html", "/display-app/_expo/static/js/web/bundle.js?v=bf75c48f57473debb615d5614eb55f4dcdce80172a7cd3a3ac42b340f6dfb88c"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/display-app/team.html b/display-app/team.html index 6906b480b66b1bfba48915f00d292265451e16f8..22b21524849f5a9a0b5c8920c398df95bc7c02c5 100644 --- a/display-app/team.html +++ b/display-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/index.html b/index.html index 8d9b23a69071c36c729cc851b12154db30029f02..1840865f5dabf99637d442cf4549a1f8c0474b05 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ -Cover Charge: try the apps (v0.3.12.196) +Cover Charge: try the apps (v0.3.12.197) @@ -63,7 +63,7 @@ footer{margin-top:28px;color:var(--muted);font-size:.8rem;text-align:center} Cover Charge logo

covercharge

All in one restaurant booking app

-

Cover Charge: try the apps (v0.3.12.196)

+

Cover Charge: try the apps (v0.3.12.197)

The Anchorage, Harbour View, Dunure

@@ -129,7 +129,7 @@ footer{margin-top:28px;color:var(--muted);font-size:.8rem;text-align:center}
-

Cover Charge v0.3.12.196

+

Cover Charge v0.3.12.197

diff --git a/owner-app/_expo/static/js/web/bundle.js b/owner-app/_expo/static/js/web/bundle.js index 91fed8b62d9bc29f7f729bcf04363bbc8d5896dc..fc8897696fb6bee97b3cf99ce72f5cba12025aca 100644 --- a/owner-app/_expo/static/js/web/bundle.js +++ b/owner-app/_expo/static/js/web/bundle.js @@ -6,11 +6,11 @@ var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow() __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},0,[1,2]); __d(function(g,r,i,a,m,e,d){},1,[]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0])},2,[3]); -__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1618]); +__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1621]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},4,[5,6]); __d(function(g,r,i,a,m,e,d){},5,[]); __d(function(g,r,i,a,m,e,d){const _='undefined'==typeof window;globalThis.__webpack_chunk_load__=_=>g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},6,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1614,1617]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1617,1620]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},8,[9]); __d(function(g,r,i,a,m,e,d){ /** @@ -24,7 +24,7 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},9,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},10,[11]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1566,1571,1572,1613]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1569,1574,1575,1616]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},12,[13,17,775,856,955,8]); __d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return Object.keys(t).forEach(function(c){"default"===c||Object.prototype.hasOwnProperty.call(n,c)||Object.defineProperty(n,c,{enumerable:!0,get:function(){return t[c]}})}),t}Object.defineProperty(e,"__esModule",{value:!0}),r(d[0]),t(r(d[1]),e),t(r(d[2]),e),t(r(d[3]),e),t(r(d[4]),e)},13,[14,15,765,766,768]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},14,[]); @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); @@ -1485,8 +1485,8 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1403,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1404,[13,17,1405,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1542,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1455,1462,1463,1464,1184,1237,1465,1446,1466,1468,1444,1155,1480,1220,1382,1222,1235,1470,1082,1084,1538,1539,1558,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1545,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1460,1467,1468,1469,1184,1237,1470,1446,1471,1473,1444,1155,1485,1220,1382,1222,1235,1475,1082,1084,1541,1542,1561,8]); __d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:O}={}){const{rid:ne,r:ie,now:ae,today:oe,me:de,role:re}=(0,w.useCtx)(1e4),ue=(0,_.useBookings)(ne),ce=(0,w.useInStaffApp)(),he=(0,w.useShiftManager)(),ge=(0,_.useWaitlist)(ne),[be,pe]=((0,_.useStore)(e=>e.alertAcks),(0,P.useState)(oe)),ke=(0,U.useFrontDoor)(be),xe=(0,y.useBookingWrite)(),me=(0,f.useSeatClearFinish)(),[we,ye]=(0,P.useState)(''),[je,fe]=(0,P.useState)(!1),[Ie,Be]=(0,P.useState)(2),De=bee.date===be).sort((e,s)=>e.time.localeCompare(s.time)),$e=ge.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=Se.filter(e=>'noshow'===e.status),Ce=(0,Z.useSync)(e=>!!e.venueId&&'guest'!==e.kind),Le=Se.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),ve=(0,p.cancelledDayTally)(ue,be),Ne=(0,p.cancelledTallyWords)(ve,be===oe?'today':'that day'),Pe=Se.filter(e=>!e.walkIn),Oe=Se.filter(e=>e.walkIn),We=ue.filter(e=>'pending'===e.status&&e.date>=oe).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Me,Ee]=(0,P.useState)(null),Ae=(0,z.parseYmd)(be);Ae.setHours(12);const Re=(0,te.hoursFor)(ie,Ae),ze=Re?.open??new Date(`${be}T12:00:00`),He=Re?.close??new Date(`${be}T21:00:00`),Ge=Re||Se.length?De?'No one seated that day':be===oe?'No bookings yet today':'No bookings yet':be===oe?'Closed today':'Closed that day',Fe=$e.length>0||je||'waitlist'===O?(0,le.jsxs)(W.default,{style:{gap:10},children:[(0,le.jsx)(F.SectionHead,{title:`Waitlist (${$e.length})`,sub:`New party waits about ${(0,H.estimateWait)($e.length+1,ie.settings.turnMins,1)} min (estimate)`}),$e.map((e,s)=>(0,le.jsxs)(W.default,{style:M.styles.card,children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,le.jsxs)(M.Muted,{children:[(0,z.minsBetween)(new Date(e.joinedAt),ae)," min \xb7 est. ",(0,H.estimateWait)(s+1,ie.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,le.jsx)(M.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,le.jsxs)(M.Row,{gap:6,children:['waiting'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>_.repo.waitlist.setStatus(e.id,'notified')}):null,me.ok?(0,le.jsx)(M.Button,{small:!0,label:"Seat",onPress:()=>_.repo.waitlist.setStatus(e.id,'seated')}):null,(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>_.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:we,onChangeText:ye,style:[M.styles.input,{flex:1}]}),(0,le.jsx)(M.Stepper,{value:Ie,onChange:Be,min:1,max:12,label:"party"})]}),(0,le.jsx)(M.Button,{kind:"secondary",label:"Add to waitlist",disabled:we.trim().length<2,onPress:()=>{_.repo.waitlist.join(ne,we.trim(),Ie),ye('')}})]}):(0,le.jsx)(M.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>fe(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===O?(0,le.jsx)(W.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Fe}):(0,le.jsxs)(W.default,{style:{gap:12},children:[(0,le.jsx)(l.BookingSaveBanner,{rid:ne}),e&&!ce&&'staff'!==re?(0,le.jsx)(M.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===ne)&&!ce&&'staff'!==re?(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"table"}):null,!s.IS_WILDINGS&&!ie.settings.hotel?.enabled||ce||'staff'===re?null:(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"room",hotel:ie.settings.hotel??n.WILDINGS_HOTEL}),(0,le.jsx)(q.BookingsDayNav,{today:oe,date:be,onDate:pe,count:e=>ue.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ue.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,le.jsx)(W.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,le.jsx)(se.DayGraph,{bare:!0,fill:!0,todays:Se,open:ze,close:He,now:ae,turnBase:ie.settings.turnMins,height:128,past:De,closed:!Re,emptyText:Ge})}),De?(0,le.jsxs)(W.default,{testID:"bookings-past-totals",style:[M.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,q.longDay)(be)}: ${Pe.length} tables, ${Le} Covers, ${Se.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${Se.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,le.jsxs)(M.T,{size:17,weight:"semibold",children:["That day: ",Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']}),(0,le.jsxs)(M.T,{size:16,colour:G.colours.text,children:[Se.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",Se.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,le.jsx)(M.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,le.jsx)(W.default,{testID:"bookings-summary",children:(0,le.jsxs)(M.T,{weight:"semibold",children:[Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']})}),ce||'staff'===re||De?null:(0,le.jsx)(h.BookingsMatchStatus,{}),(0,le.jsx)(W.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ne,style:{alignItems:'center'},children:(0,le.jsx)(M.T,{size:15,colour:G.colours.muted,center:!0,children:Ne})}),(0,le.jsxs)(W.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[De||ce&&!he?null:(0,le.jsx)(T.QuietButton,{label:"New booking",onPress:ke.openBooking,testID:"add-booking",disabled:!xe.ok,accessibilityHint:xe.hint}),ce&&he&&be===oe?(0,le.jsx)(T.QuietButton,{label:"Walk-in",onPress:ke.openWalkIn,testID:"add-walkin",disabled:!xe.ok,accessibilityHint:xe.hint}):null,be===oe?(0,le.jsx)(C.CloseGardenButton,{quiet:!0,short:!0,rid:ne,r:ie,now:ae,by:de}):null]}),We.length?(0,le.jsxs)(W.default,{testID:"pending-requests",style:[M.styles.card,{borderColor:G.colours.amber,gap:8}],children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:G.colours.amber,children:["Needs confirming (",We.length,")"]}),(0,le.jsx)(M.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),We.map(e=>(0,le.jsxs)(W.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:G.colours.border},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,le.jsxs)(M.Muted,{children:[(0,z.niceDate)((0,z.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,le.jsxs)(M.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie}),'staff'!==re&&((0,v.needsHoldOk)(e)||e.date===oe&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,v.needsHoldOk)(e)?(0,le.jsx)(M.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,L.confirmHolds)(e.id,de)}):null,e.holdOk&&'seated'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,L.serveHolds)(e,de,'owner')}):null]}):null,Me===e.id?(0,le.jsxs)(W.default,{style:{gap:6},children:[(0,le.jsxs)(M.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{_.repo.bookings.decide(e.id,'declined',de),Ee(null)}}),(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ee(null)})]})]}):xe.ok?(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>_.repo.bookings.decide(e.id,'confirmed',de)}),(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ee(e.id)}),(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"change"})]}):(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),(0,le.jsx)(J.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Se.length?(0,le.jsx)(M.Muted,{children:"No bookings for this day yet."}):null,Se.map(e=>{const s='confirmed'===e.status&&be===oe&&(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,R.gbp);return(0,le.jsxs)(W.default,{testID:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[M.styles.card,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,N.seatedHighlightStyle)({borderColor:(0,v.hasAllergens)(e)?G.colours.red:G.colours.goldLight}):{borderColor:(0,v.hasAllergens)(e)?G.colours.red:s?G.colours.amber:G.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,le.jsx)(L.AllergenBar,{b:e}),(0,le.jsx)(l.BookingNotSavedLine,{b:e}),(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?N.SEATED_FG:G.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,v.hasAllergens)(e)?(0,le.jsx)(E.AllergyIcon,{text:(0,v.allergenText)(e),size:20,colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?'#7A4A00':G.colours.amber,ink:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?G.colours.gold:G.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,le.jsx)(M.Badge,{kind:'seated'===(0,v.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,v.shownStatus)(e)[0].toUpperCase()+(0,v.shownStatus)(e).slice(1)})]}),n?(0,le.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,le.jsxs)(M.T,{size:14,colour:N.SEATED_MUTED,children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,le.jsxs)(M.Muted,{children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,le.jsxs)(M.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,le.jsx)(M.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie,only:"rules"}),(0,b.historyLines)(e)[0]?(0,le.jsxs)(M.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[De||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>_.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:de,depositPaidAt:(new Date).toISOString()})}),De?null:(0,le.jsx)(S.WixDepositLink,{b:e,rid:ne}),De||!xe.ok||ce&&!he?null:(0,le.jsx)(D.WaiveDepositButton,{b:e,who:de,small:!0}),'waived'===t&&e.depositWaived?(0,le.jsx)(M.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,le.jsx)(M.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,le.jsxs)(M.Muted,{children:[(0,X.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,v.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,le.jsx)(Q.BookingAllergyChain,{b:e,me:de}):null,e.walkIn?null:(0,le.jsx)(J.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,le.jsxs)(M.T,{size:13,colour:G.colours.amber,children:["Running ",(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)," min late. Call them, then mark no-show if needed."]}):null,xe.ok?(0,le.jsx)(c.BookingEditButton,{rid:ne,booking:e,who:de,role:re,inStaffApp:ce,shiftManager:he,big:!0,testID:`edit-booking-${e.id}`}):null,(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,le.jsx)(u.BookingTableButton,{rid:ne,booking:e,readOnly:De||!xe.ok,turnBase:ie.settings.turnMins,canClear:me.ok}),xe.ok?null:(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),xe.ok?(0,le.jsxs)(le.Fragment,{children:[De||e.table||!['seated','confirmed'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>ke.assignTable(e)}),!De&&['seated','confirmed'].includes(e.status)?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>ke.combineTables(e)}):null,De||'confirmed'!==e.status?null:(0,le.jsxs)(le.Fragment,{children:[me.ok&&e.date===oe?(0,le.jsx)(M.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(ne,e)}):null,(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>_.repo.bookings.setStatus(e.id,'noshow')})]}),De||e.walkIn?null:(0,le.jsx)(r.CancelBookingButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),De||e.walkIn?null:(0,le.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:oe}),De||'seated'!==e.status?null:(0,le.jsx)(K.FinishButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),allowed:me.ok,hint:me.hint,small:!0,a11y:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=oe?(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"auto"}):null,ce?null:(0,le.jsx)($.CopyReviewLink,{rid:ne,bookingId:e.id}),!De&&e.walkIn?(0,le.jsx)(d.CancelWalkInButton,{rid:ne,b:e,small:!0}):null,!De&&e.walkIn?(0,le.jsx)(d.ReinstateWalkInButton,{rid:ne,b:e,today:oe,small:!0}):null,(0,le.jsx)(Y.BookingUndo,{b:e,rid:ne,today:oe,who:(0,U.walkInLabel)(e),allowed:me.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,le.jsx)(M.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,le.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ue,be,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:be===oe?'today':'that day'}),(0,le.jsxs)(M.Card,{children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsx)(M.T,{weight:"semibold",children:"No-shows"}),(0,le.jsx)(M.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${be===oe?'today':(0,z.niceDate)((0,z.parseYmd)(be)).slice(0,6)}${Ce||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,le.jsx)(M.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${Te.length>6?` and ${Te.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,le.jsx)(t.GreensideCashOnly,{}):(0,le.jsxs)(M.Card,{children:[(0,le.jsx)(M.T,{weight:"semibold",children:"Deposits"}),(0,le.jsx)(M.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ie.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,le.jsx)(M.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Fe,ke.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),w=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=(e=O)&&e.__esModule?e:{default:e},M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),F=_r(_d[40]),U=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53])},1407,[805,1408,1093,1261,1409,812,822,1113,1114,1089,1118,1410,1119,1115,1395,1396,1055,1331,994,1116,1087,841,1122,1412,1231,1413,1387,1076,1053,1088,17,85,777,1353,858,845,851,863,1313,804,1178,1096,1111,996,1348,1060,1156,1414,1222,946,1180,1392,862,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1408,[]); __d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1409,[806,17,85,777,946,1265,8]); @@ -1500,7 +1500,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1417,[17,278,85,777,857,804,1418,8]); __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1418,[]); __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{background-image:radial-gradient(1.2px 1.2px at 23px 41px,#fff,transparent),radial-gradient(1px 1px at 97px 13px,#fff9,transparent),radial-gradient(1.4px 1.4px at 151px 120px,#f5e6c8,transparent),radial-gradient(1px 1px at 61px 163px,#fffa,transparent),radial-gradient(1.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1419,[888,813,17,1067,319,219,385,278,24,85,856,885,876,816,946,966,878,776,804,884,777,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ae,me:ne,today:ie}=(0,A.useCtx)(5e3),re=(0,p.useOrders)(n),de=(0,p.useBookings)(n),ce=(0,p.useWaitlist)(n),he=(0,p.useEvents)(n),ye=(0,p.useRatings)(n),xe=(0,j.useOwner)(e=>e.staff),me=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),be=(0,j.useOwner)(e=>e.shifts),fe=(0,M.useRealHistory)(n,F),pe=(0,l.useMemo)(()=>(0,s.forecastToday)(x,de,re,he,F,fe??void 0),[x,de,re,he,fe,F.getTime()/6e4|0]),je=(0,S.useExamples)(),ke=(0,N.useCashUp)(e=>e.cashUps),we=de.filter(e=>e.date===ie),$e=re.filter(B.LIVE),ve=ce.filter(e=>'waiting'===e.status||'notified'===e.status),Ie=(0,C.seatedCoversOn)(de,ie),Ce=(0,oe.coversSplit)(we,ie),De=$e.filter(e=>(0,_.chainNeedsAction)(e,de)),Te=we.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,$e)),Be=$e.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Ae=pe.nextHour,Le=(0,B.busyLevel)(Ae?.coversHigh??0,pe.busy.busy),Me=(0,B.restOfDayLevel)(pe,x),Se=re.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===ie).reduce((e,t)=>e+t.paid,0),Ne=(0,R.tradingDay)(F),Pe=je?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Fe=je?{today:186e3+Se,last:Pe?{date:(0,I.ymd)(Pe.date),pence:Pe.total}:null,online:0,show:!0}:(0,O.takingsToday)(ke,n,Ne,Se),We=j.CAN.takings(ae)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),He=(0,l.useMemo)(()=>(0,L.insights)(x,de,re,he,ye,F,Ie),[x.id,de.length,ye.length,Ie]),Re=((0,A.weekday)(F),(0,k.openWorkingRows)(me,ie)),Oe=(0,ee.useFrontDoor)(ie),ze=(0,u.useBookingWrite)(),Ee=(0,w.useOutstanding)(),Ge=(0,i.useTravelDay)('owner',ie),Ue=(0,A.useSignedIn)(),qe=(0,A.useInStaffApp)(),Ye=(0,P.canSeeMonthTakings)(ae,Ue,{inStaffApp:qe,live:(0,H.isLive)()}),Ke=(0,W.homeSetupNagsHidden)(n),Ve=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Qe,Xe]=(0,l.useState)(!1),[Ze,Je]=(0,l.useState)(!1),et=ne.replace(' (example)',''),tt=j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ge?(0,le.jsxs)(b.default,{style:{gap:12},children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(i.DayView,{rid:n,day:Ge,today:ie,app:"owner"})]}):(0,le.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(V.AssistantPendingCard,{}),Ue&&'owner'!==Ue.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,Ue?(0,le.jsx)(X.MyTasksToday,{rid:n,staffId:Ue.id,name:Ue.name,onShift:(0,J.shiftNow)(Ue.id,Date.now()).on}):null,'staff'!==ae?(0,le.jsx)(Z.TodaysTipsCard,{rid:n,today:ie}):null,'staff'!==ae?(0,le.jsx)(Z.TipsPotCard,{rid:n,today:ie}):null,j.CAN.manage(ae)?(0,le.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,le.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,le.jsx)(ge,{split:Ce}),(0,le.jsx)(te.BlocksBanner,{rid:n,now:F,by:ne}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ie,by:ne,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ke?(0,le.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ke?(0,le.jsx)(o.SeasonsTodo,{go:e}):null,(0,le.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Xe(!0),style:{minHeight:56}}),(0,le.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(c.QuietButton,{label:"New booking",onPress:Oe.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),j.CAN.manage(ae)?(0,le.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ne}):null]}),Oe.elements,j.CAN.manage(ae)?(0,le.jsx)(Y.PaydaysCard,{go:e}):null,(0,le.jsx)(E.FadeIn,{children:(0,le.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Ae?` \xb7 ${(0,A.fmtH)(Ae.hour)}\u2013${(0,A.fmtH)(Ae.hour+1)}`:'']}),pe.example?(0,le.jsx)(M.ExampleBadge,{}):pe.enough?(0,le.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(E.Gauge,{pct:Ae?Le.pct:0,label:Ae?Le.label:pe.open?'Kitchen closing':'Closed today',sub:Ae&&!pe.enough?`${Ae.booked} booked${Ae.walkIns?` + ${Ae.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Ae?`Estimated ${(0,s.coversRange)(Ae.coversLow,Ae.coversHigh)} \xb7 Busy at ${pe.busy.busy} Covers an hour \xb7 ${Ae.booked} booked + about ${Ae.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Ae.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[pe.enough?(0,le.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,pe.enough?(0,le.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(pe.restOfDay.low,pe.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${pe.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${pe.restOfDay.booked} Covers`})]}),pe.flags.length?(0,le.jsxs)(f.Muted,{center:!0,children:["Calendar: ",pe.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||$e.length?(0,le.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Live orders",value:"",accent:$e.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${$e.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${$e.filter(e=>'table'===e.type).length} table`:`${$e.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(E.CountUp,{value:$e.length})})}):null,ve.length>0?(0,le.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,le.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,le.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(z.TakingsTodayCard,{t:Fe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:De.length+Te.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(E.CountUp,{value:De.length+Te.length,colour:De.length+Te.length?T.colours.red:T.colours.ok})})})]}),De.length+Te.length+Be.length?(0,le.jsx)(B.SectionHead,{title:"Needs action now"}):null,De.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ne,compact:!0})]},e.id)),Te.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ne})]},e.id)),Be.map(t=>(0,le.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(f.T,{size:14,children:t.detail}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ee.days.length||Ee.requests)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ee.days.length?`${Ee.days.length} earlier day${Ee.days.length>1?'s':''} to sign off`:''}${Ee.days.length&&Ee.requests?' \xb7 ':''}${Ee.requests?`${Ee.requests} correction request${Ee.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&j.CAN.publishSocial(ae)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(B.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(f.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(B.SectionHead,{title:e})}),(0,le.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(f.Badge,{kind:"ok",label:`${Re.length} clocked in`})}),(0,le.jsxs)(f.Card,{children:[0===Re.length?(0,le.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Re.map(e=>{const t=xe.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(be,e.staffId,ie),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,le.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,le.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,le.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ae?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(B.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((t,s)=>(0,le.jsx)(E.FadeIn,{delay:100+90*s,children:(0,le.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,le.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,le.jsx)(f.Muted,{children:t.body}),t.action?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ye?(0,le.jsx)(f.Button,{testID:"home-takings-button",kind:Ze?'secondary':'primary',label:Ze?'Hide takings':'Takings',accessibilityLabel:Ze?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>Je(e=>!e),style:{minHeight:56}}):null,Ye&&Ze?(0,le.jsx)(E.FadeIn,{children:(0,le.jsx)(ue,{rid:n,today:ie})}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Qe,onClose:()=>Xe(!1),rid:n,by:et,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ce,_e.MonthTakingsCard=ue,_e.WalkInSplitCard=ge;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]);const ae=18,ne=18,ie=150,re=34;function de(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sae+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function ue({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ce(k,r):[],z=(e,t,s,l,a)=>(0,le.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,le.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,le.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,le.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,le.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,le.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,le.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,le.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,le.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ie,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:ae,y1:$,x2:r-ne,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:`${de(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:de(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,le.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,le.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,le.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,le.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ie,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,le.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:re,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,le.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const he='#3A2F1E';function ge({split:e}){return(0,le.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:he,borderWidth:1,borderColor:T.colours.gold},children:[(0,le.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,le.jsx)(b.default,{style:{flex:1,backgroundColor:he}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ne,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(n),ce=(0,p.useBookings)(n),ue=(0,p.useWaitlist)(n),ge=(0,p.useEvents)(n),xe=(0,p.useRatings)(n),me=(0,j.useOwner)(e=>e.staff),be=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),fe=(0,j.useOwner)(e=>e.shifts),pe=(0,M.useRealHistory)(n,F),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,F,pe??void 0),[x,ce,de,ge,pe,F.getTime()/6e4|0]),ke=(0,S.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),ve=de.filter(B.LIVE),Ie=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=ve.filter(e=>(0,_.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,ve)),Ae=ve.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Me=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Se=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(F),Fe=ke?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,We=ke?{today:186e3+Ne,last:Fe?{date:(0,I.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,n,Pe,Ne),He=j.CAN.takings(ne)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,F,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(F),(0,k.openWorkingRows)(be,re)),ze=(0,ee.useFrontDoor)(re),Ee=(0,u.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,i.useTravelDay)('owner',re),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,P.canSeeMonthTakings)(ne,qe,{inStaffApp:Ye,live:(0,H.isLive)()}),Ve=(0,W.homeSetupNagsHidden)(n),Qe=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Xe,Ze]=(0,l.useState)(!1),[Je,et]=(0,l.useState)(!1),tt=ie.replace(' (example)',''),st=j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,ae.jsxs)(b.default,{style:{gap:12},children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(i.DayView,{rid:n,day:Ue,today:re,app:"owner"})]}):(0,ae.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(K.WhoBar,{}),(0,ae.jsx)(V.AssistantPendingCard,{}),qe&&'owner'!==qe.role?(0,ae.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ae.jsx)(X.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ne?(0,ae.jsx)(Z.TodaysTipsCard,{rid:n,today:re}):null,'staff'!==ne?(0,ae.jsx)(Z.TipsPotCard,{rid:n,today:re}):null,j.CAN.manage(ne)?(0,ae.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ae.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,ae.jsx)(le.SuperProInsights,{go:e}),(0,ae.jsx)(ye,{split:De}),(0,ae.jsx)(te.BlocksBanner,{rid:n,now:F,by:ie}),(0,ae.jsx)(y.KitchenSignoffs,{rid:n,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ne)}),j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(o.SeasonsTodo,{go:e}):null,(0,ae.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,ae.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:Ee.hint,disabled:!Ee.ok,onPress:()=>e('more','blocks')}):null,(0,ae.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,ae.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ae.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ne)?(0,ae.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ie}):null]}),ze.elements,j.CAN.manage(ne)?(0,ae.jsx)(Y.PaydaysCard,{go:e}):null,(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Le?` \xb7 ${(0,A.fmtH)(Le.hour)}\u2013${(0,A.fmtH)(Le.hour+1)}`:'']}),je.example?(0,ae.jsx)(M.ExampleBadge,{}):je.enough?(0,ae.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ae.jsx)(E.Gauge,{pct:Le?Me.pct:0,label:Le?Me.label:je.open?'Kitchen closing':'Closed today',sub:Le&&!je.enough?`${Le.booked} booked${Le.walkIns?` + ${Le.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Le?`Estimated ${(0,s.coversRange)(Le.coversLow,Le.coversHigh)} \xb7 Busy at ${je.busy.busy} Covers an hour \xb7 ${Le.booked} booked + about ${Le.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Le.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ae.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Se.level.label}${Se.peak?`, peak ${(0,A.fmtH)(Se.peak.hour)}`:''}`}):null,je.enough?(0,ae.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(je.restOfDay.low,je.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${je.restOfDay.takeaway} takeaways`:''}`}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ae.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||ve.length?(0,ae.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Live orders",value:"",accent:ve.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${ve.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${ve.filter(e=>'table'===e.type).length} table`:`${ve.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ae.jsx)(E.CountUp,{value:ve.length})})}):null,Ie.length>0?(0,ae.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${Ie.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ae.jsx)(E.CountUp,{value:Ie.length})})}):null,He&&We.show?(0,ae.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(z.TakingsTodayCard,{t:We,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ae.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:Te.length+Be.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,ae.jsx)(E.CountUp,{value:Te.length+Be.length,colour:Te.length+Be.length?T.colours.red:T.colours.ok})})})]}),Te.length+Be.length+Ae.length?(0,ae.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ae.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ae.jsx)(f.T,{size:14,children:t.detail}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ne)&&(Ge.days.length||Ge.requests)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,ae.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ne)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ae.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ae.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ae.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,ae.jsxs)(f.Row,{gap:4,children:[(0,ae.jsx)(G.Mark,{p:"facebook"}),(0,ae.jsx)(G.Mark,{p:"instagram"}),(0,ae.jsx)(G.Mark,{p:"tiktok"}),(0,ae.jsx)(G.Mark,{p:"youtube"})]}),(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ae.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ae.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ae.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ae.jsx)(B.SectionHead,{title:e})}),(0,ae.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ae.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ae.jsxs)(f.Card,{children:[0===Oe.length?(0,ae.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Oe.map(e=>{const t=me.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(fe,e.staffId,re),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,ae.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ae.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ae.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ae.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ne?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(B.SectionHead,{title:"Insights",sub:ke?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),Re.slice(0,4).map((t,s)=>(0,ae.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ae.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,ae.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,ae.jsx)(f.Muted,{children:t.body}),t.action?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ke?(0,ae.jsx)(f.Button,{testID:"home-takings-button",kind:Je?'secondary':'primary',label:Je?'Hide takings':'Takings',accessibilityLabel:Je?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>et(e=>!e),style:{minHeight:56}}):null,Ke&&Je?(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsx)(he,{rid:n,today:re})}):null,(0,ae.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:tt,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ue,_e.MonthTakingsCard=he,_e.WalkInSplitCard=ye;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]),ae=_r(_d[56]);const ne=18,ie=18,re=150,de=34;function ce(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sne+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function he({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yne+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ue(k,r):[],z=(e,t,s,l,a)=>(0,ae.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,ae.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ae.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ae.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,ae.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,ae.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ae.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,ae.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ae.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ae.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ae.jsxs)(n.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ae.jsx)(a.Defs,{children:(0,ae.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ae.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ae.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ae.jsx)(a.Line,{x1:ne,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:`${ce(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:ce(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,ae.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ae.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,ae.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,ae.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ae.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ae.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ae.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ae.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ae.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ae.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,ae.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ae.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ae.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ae.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,ae.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ae.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ae.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ge,borderWidth:1,borderColor:T.colours.gold},children:[(0,ae.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ae.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,1455,8]); __d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:$}=(0,D.useCtx)(6e4),V=$.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsx)(j.Toggle,{label:`${e.name}: no deposit, paid on the night`,value:!!e.payOnNight,onChange:s=>pe(e.id,{payOnNight:s})}),e.payOnNight?null:(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Pre-order deposit each"}),(0,W.jsx)(K,{label:`${e.name} pre-order deposit`,min:0,max:200,value:Math.round((e.depositPence??0)/100),unit:e=>e?`\xa3${e}`:'None',onChange:s=>pe(e.id,{depositPence:100*s||void 0})})]}),(0,W.jsx)(j.Muted,{size:12,children:e.uses.length?`Uses: ${e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')} from the counted stock. Held from the Display count and shown as \u201cReserved\u201d.`:'Not taken from the counted stock.'})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),Re=J.hourOverrides??[],De=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:R.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),De?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:De}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!De,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),Re.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:Re.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...Re.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),$e=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,ze]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{ze(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From this many adults"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from this many adults"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:R.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more adults see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)(z.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:$e,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:R.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:R.colours.accentBorder,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:R.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:R.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,D.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:R.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:R.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:R.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),$=_r(_d[31]),I=_r(_d[32]),z=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:R.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?R.colours.red:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:R.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:R.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:R.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:R.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,$.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:R.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1421,[1051,1031,805,1408,812,1422,1423,1425,1426,1427,1197,1029,1030,1006,1012,17,385,85,777,841,1428,816,862,1053,861,804,1055,858,1181,972,973,876,1429,1382,996,1430,1003,1139,939,8]); __d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1422,[812,17,85,777,1137,861,804,8]); __d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1423,[843,17,219,85,777,858,996,1150,1254,946,1325,1424,8]); @@ -1535,170 +1535,173 @@ __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule' __d(function(_g,_r,i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1452,[17,264,385,85,777,804,961,1453,8]); __d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1453,[892,946,876,856,961]); __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssistantPendingCard=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),t=b(),[n,o]=(0,s.useState)(null),l=async()=>{try{o(await(0,r.assistantProposalsList)())}catch{o([])}};return(0,s.useEffect)(()=>{if(!e||!t)return;l();const s=setInterval(()=>{l()},2e4);return()=>clearInterval(s)},[e,t]),e&&t?(0,u.jsx)(y,{rows:n,onChanged:()=>{l()},compact:!0}):null},_e.AssistantsPage=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[t,l]=(0,s.useState)(''),[h,b]=(0,s.useState)(null),[x,f]=(0,s.useState)(!1),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),[v,D]=(0,s.useState)(null),I=async()=>{try{w(await(0,r.assistantList)())}catch{w([])}try{T(await(0,r.assistantProposalsList)())}catch{T([])}};(0,s.useEffect)(()=>{e&&I()},[e]);const C=t.replace(/\D/g,''),P=async()=>{f(!0),b(null);const e=await(0,r.assistantApprove)(C);f(!1),e.ok?(l(''),b({ok:!0,text:'Done. Tracy\u2019s assistant is paired. It can look things up and propose changes, which wait for Tracy to confirm on her phone.'}),I()):b({ok:!1,text:e.message})};return(0,u.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,u.jsx)(y,{rows:k,onChanged:()=>{I()}}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair Tracy\u2019s assistant"}),(0,u.jsx)(o.T,{center:!0,children:"Ask Tracy\u2019s Grok Bot to start CoverCharge sign-in. It will show 6 numbers."}),(0,u.jsx)(o.T,{center:!0,children:"Only an owner can approve this. The bot can look things up and advise, and it can propose a change. Nothing is changed until Tracy confirms it on her phone. Important changes \u2014 permissions, opening hours, the table plan, cancelling or moving a booking, pay, menus, stock or price, online settings, or any delete \u2014 ask her a second time, with a plain warning of what is affected."}),(0,u.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:t,onChangeText:e=>l(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,u.jsx)(o.Button,{testID:"assistant-approve",label:x?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs Tracy\u2019s Grok Bot as an assistant for The Anchorage",disabled:!e||x||6!==C.length,onPress:()=>{P()},style:{minHeight:56}}),e?null:(0,u.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,u.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!h,accessibilityLabel:h?.text,children:h?(0,u.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:h.ok?c.colours.goldLight:c.colours.amber,children:h.text}):null}),(0,u.jsx)(o.Muted,{center:!0,children:"Never send Tracy\u2019s personal app link to the bot. That link stays on her phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, and it cannot change its own access or pairing."})]}),(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,u.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,u.jsx)(o.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,u.jsx)(o.Button,{testID:`assistant-revoke-${e.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>D(e),style:{minHeight:56}})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),v?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>D(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,u.jsx)(o.T,{center:!0,children:`${v.label} stops working straight away. Any changes still waiting are cancelled. Tracy\u2019s phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,u.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=v;D(null);const s=await(0,r.assistantRevoke)(e.id);b(s.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:s.message}),I()},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>D(null),style:{minHeight:56}})]}):null]})};var e,s=_r(d[0]),t=_r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},o=_r(d[2]),r=_r(d[3]),l=_r(d[4]),c=_r(d[5]),h=_r(d[6]),u=_r(d[7]);const p=e=>e?`${(0,l.niceDate)(new Date(e))} at ${(0,l.hm)(new Date(e))}`:'not yet';function b(){const e=(0,h.useSignedIn)(),s=(0,r.useSync)(e=>e.staffRef);return'st-tracy'===e?.id||'st-tracy'===s}function y({rows:e,onChanged:t,compact:l}){const h=b(),y=(e??[]).filter(e=>'pending'===e.status),[x,f]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),v=async(e,s,n=!1)=>{f(e.id),w(null);const o=await(0,r.assistantProposalDecide)(e.id,s,n);f(null),o.ok?(T(null),w('decline'===s?'Declined. Nothing was changed.':'Done. The change has been made, as Tracy\u2019s assistant (confirmed by Tracy).'),t?.()):w(o.message)};return!y.length&&l?null:(0,u.jsx)(n.default,{testID:l?'assistant-pending-home':'assistant-pending-list',children:(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:h?'Waiting for you to confirm':'Waiting for Tracy to confirm'}),e?y.length?y.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,u.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${p(e.expiresAt)}.`:'']}):e.expiresAt?(0,u.jsx)(o.Muted,{center:!0,children:`Runs out at ${p(e.expiresAt)}.`}):null,h&&e.canDecide?(0,u.jsxs)(n.default,{style:{gap:8},children:[(0,u.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:x===e.id?'Working\u2026':'Approve',accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!x,onPress:()=>{e.needsDoubleConfirm?T(e):v(e,'approve')},style:{minHeight:56}}),(0,u.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",disabled:!!x,onPress:()=>{v(e,'decline')},style:{minHeight:56}})]}):(0,u.jsx)(o.Muted,{center:!0,children:"Only Tracy can confirm or decline this on her phone."})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,u.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),j?(0,u.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:j}):null,k?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>T(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:k.warning||k.summary}),(0,u.jsx)(o.T,{center:!0,children:"This is an important change to how the venue works. Please read it carefully, then confirm again. Nothing is changed until you do."}),(0,u.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:x===k.id?'Working\u2026':'Yes, make this change',disabled:!!x,onPress:()=>{v(k,'approve',!0)},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",disabled:!!x,onPress:()=>T(null),style:{minHeight:56}})]}):null]})})}},1454,[17,85,777,946,863,804,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1455,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1456,804,856,1055,1457,1460,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1456,[1032]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1457,[812,17,362,385,278,85,777,1458,1459,804,1455,1055,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1458,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1459,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1460,[17,385,85,777,860,1459,996,842,1461,1456,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1461,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1462,[813,17,266,347,219,385,85,831,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1463,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1464,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1465,[831]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1466,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1467,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1467,[17,85,777,858,851,946,804,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return fe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),A=_r(d[19]),R=_r(d[20]),T=_r(d[21]),M=_r(d[22]),O=_r(d[23]),G=_r(d[24]),B=_r(d[25]),E=_r(d[26]),x=_r(d[27]),I=_r(d[28]),D=_r(d[29]),L=(e=D)&&e.__esModule?e:{default:e},N=_r(d[30]),_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),pe=_r(d[59]),ge=_r(d[60]),he=_r(d[61]),be=_r(d[62]);const fe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},ye=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:ye,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>ye(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:ye,C:G.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:ye,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>ye(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:ye,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:ye,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:ye,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:ye,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:ye,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:ye,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:ye,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:ye,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:ye,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:ye,C:A.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:ye,C:R.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:ye,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:ye,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:ye,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:ye,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:ye,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:ye,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:ye,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:I.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>fe(),C:I.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:ye,C:I.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:ye,C:I.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:I.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:ye,C:I.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:ye,C:I.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:ye,C:I.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:ye,C:I.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:I.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>L.default.createElement(_.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:N.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:N.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:_.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:H.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:Q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:ye,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:ye,C:Q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:ye,C:q.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:ye,C:q.DisplaySettingsPage}]);const Ce=e=>'owner'===e||'manager'===e;F.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Ce,C:F.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Ce,C:F.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:W.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:U.AssistantsPage}]);const Se=e=>'owner'===e||'manager'===e,ke=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},ve=e=>Se(e)&&ke();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:Se,C:V.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:ve,C:V.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:ve,C:V.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:ve,C:V.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:Se,C:V.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:Se,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:V.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:ye,C:Y.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:ye,C:Y.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:ye,C:Y.Outbox}]);const we=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:we,C:K.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:K.optinsAllowed,C:K.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:we,C:z.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:we,C:j.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:we,C:$.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:we,C:J.OrderSheetSettings},...X.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:we,C:(0,j.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:we,C:Z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:we,C:ee.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:ye,C:ee.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:we,C:ee.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:we,C:te.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:ye,C:se.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:ye,C:se.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:ye,C:se.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:ye,C:ae.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:ye,C:ie.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:ye,C:oe.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:ye,C:ne.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ne.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ue.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ce.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:Se,C:function(){const{rid:e,today:t}=(0,le.useCtx)(6e4);return L.default.createElement(ce.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:ye,C:re.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:ye,C:ge.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:ye,C:he.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:be.UseOnComputerPage}])},1468,[822,1048,856,1469,876,966,955,816,866,1471,1478,1486,1446,1487,1488,1490,1491,1155,1464,1492,1493,1495,1196,1187,1466,1496,1444,1497,1499,17,1193,1176,1445,1433,1447,1480,1504,1505,1454,1506,1436,1421,1507,1451,1508,886,1509,1510,1512,1182,1455,1513,1382,1457,1525,1079,1055,1197,1149,1528,1531,1534,1537]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1469,[17,378,219,385,85,19,777,1024,1327,876,804,1470,1184,1465,1055,8,260]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1470,[831]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1471,[812,1442,17,851,85,777,876,804,1055,884,885,1472,946,962,1029,1440,1473,1474,1476,994,1477,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1472,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1473,[812,17,85,777,804,876,1343,1342,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1474,[17,85,777,1475,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1475,[831,892,946,880]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1476,[17,85,777,804,960,1020,946,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1477,[892,946]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1478,[17,85,777,835,876,1479,804,1055,1480,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1479,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1480,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1481,1485,804,1055,1069,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1481,[1482,1484,1483]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1482,[843,1483]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1483,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1484,[1482,891]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1485,[869,824,831,834]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1486,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1487,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1488,[1037,17,85,1489,814,857,777,876,804,1055,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1489,[812,17,219,385,85,780,814,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1490,[17,1151,847,1055,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1491,[17,1030,1055,946,961,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1492,[17,1388,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1493,[17,85,780,777,858,1006,1494,804,1055,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1494,[839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1495,[17,85,1336,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1496,[17,776,1055,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1497,[17,85,777,858,1006,876,1053,1498,946,804,1232,1233,1055,8]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1498,[839,1494]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1499,[805,1408,812,822,843,1500,1427,1470,1218,841,1254,946,1501,1503,1428,17,1096,1478,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1500,[843,17,85,777,845,851,1150,858,853,804,8]); -__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1501,[946,17,264,219,85,1272,777,1251,1254,804,1502,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1502,[17,219,85,777,1251,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1503,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1504,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1505,[17,85,777,946,863,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1506,[813,812,822,17,219,385,85,777,1220,858,1485,848,1222,1016,804,1025,1055,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1507,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1508,[17,385,85,777,876,998,851,999,804,840,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1509,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1510,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1511,804,880,1157,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1511,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1512,[17,85,777,804,1423,1500,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1513,[812,1031,779,17,385,85,777,876,1462,1514,1515,1516,804,1055,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1514,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1515,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1516,[1517,1098,843,1518,1519,876,858,996,1462,1514,1515,1521,1520,1523,1524,994,995]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1517,[1062,1061,1021]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1518,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1519,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1520,1518]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1520,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1521,1522]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1521,[824,831,834]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1522,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1523,[816,876,956,851,1520,1015,1069]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1524,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1525,[17,362,85,777,804,1458,1521,1470,1522,1352,890,1526,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1526,[17,85,777,804,1527,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1527,[824,831,834]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1528,[17,779,85,777,845,1251,1529,1530,804,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1529,[845]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1530,[946,1529,1254]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1531,[17,85,777,858,1006,1532,938,839,1533,1018,804,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1532,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1533,[839,1007,1494]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1534,[812,17,85,777,1535,1019,804,1536,1055,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1535,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1536,[1018,1019,935,892,946]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1537,[17,264,219,85,777,812,804,946,1418,1182,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1538,[219]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1540,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1541,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1462,1084,1082,1222,1235,938,876,1030,1470,880,946,804,1327,1542,1055,1480,1407,1155,1464,1466,1455,1446,1468,1538,1540,1548,1549,1550,1553,1556,8]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1542,[17,266,347,219,385,278,85,409,780,779,1327,1446,1468,1407,1155,1466,1464,1055,1024,777,858,876,863,946,880,804,1543,1544,1545,1546,1547,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1543,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1544,[17,780,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1545,[17,85,777,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1546,[17,385,1157,1158,816,805,777,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1547,[17,219]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1548,[1543]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1549,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1550,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1551,1540,1549,1552,8]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1551,[17,385,278,85,777,804,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1552,[17,85,780,777,804,1551,1549,8]); -__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1553,[17,264,385,85,780,777,858,876,1554,961,1208,1453,804,1544,1055,1551,1555,1549,1552,1550,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1554,[831,834,824]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1555,[961]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1556,[17,85,777,804,1557,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1557,[]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1558,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1462,1085,1084,1082,1470,1222,880,804,1480,1407,1155,1055,1420,1464,1455,1466,1446,1468,1559,1538,1561,1563,1565,1562,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1559,[17,278,85,1489,857,777,876,814,1447,804,1560,1561,1562,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1560,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1561,[17]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1562,[17,85,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1563,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1560,1561,1562,1564,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1564,[876]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1565,[17,85,777,876,1058,804,1560,1561,1562,1049,1564,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1566,[13,17,856,1567,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1567,[1447,1568,813,958,1070,1500,1202,1203,1026,1023,1024,1501,1528,1503,1149,938,979,1569,976,880,1029,1030,1476,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1492,1487,1510,1570,1415,966,219,1237,1176,1182,1445,1196,1193,1463,1179,878,1205,1206,884,776,946,8]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1568,[17,85,777,1055,946,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1569,[219,977]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1570,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[13,17,856,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1572,[1440,946,778,1401,1573,993,13,1600,479,17,368,319,219,24,85,805,857,1063,856,1602,19,858,996,876,804,1415,966,987,1603,1604,1026,1605,1102,880,1006,960,1608,1372,8,1609,1610,1611,1612]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1573,[1574,1597,1599]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1574,[198,1575,1578,1592,1593,1594,1595,1596]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1575,[198,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1576,[1577]); -__d(function(g,r,i,a,m,e,d){},1577,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1578,[1579,198,1575,1592,1593]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1579,[1580,1581,1591]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1580,[1581,1585,1590]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1581,[198,355,1582,1586,1587,1588,1589,1585,1590]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1582,[198,1583,322,263,1584,1585]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1583,[487]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1584,[198,322]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1585,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1586,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1587,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1588,[1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1589,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1590,[355,1584]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1591,[17,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1592,[1579,198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1593,[1579,1592]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1594,[1575]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1595,[198,1575,1578,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1596,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1597,[198,37,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1598,[198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1599,[17,1574]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1600,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1601,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1602,[17,24,85,409,777,857,966,946,880,805,804,1543,1545,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1603,[951,868,867,946]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1604,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1605,[805,779,812,17,368,266,347,363,219,385,278,409,85,1480,1351,880,780,1055,878,876,777,804,1516,891,1606,1514,1515,1470,1352,1527,890,1607,1524,8,260]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1606,[876,816,996]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1607,[831]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1608,[]); -__d(function(e,o,s,p,t,n,a){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1609,[]); -__d(function(o,e,s,p,t,c,d){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1610,[]); -__d(function(o,e,s,p,t,d,f){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1611,[]); -__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1612,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1613,[13,17,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1614,[1615]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1615,[8,1616,574]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1616,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1617,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1618,[8,482,17,253,634]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHTS_PLAN_LABEL",{enumerable:!0,get:function(){return D}}),_e.useInsightsAccess=S,_e.SuperProInsights=B,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,v.jsx)(n.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,v.jsx)(B,{go:e})}):(0,v.jsx)(_,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.sales)return(0,v.jsx)(_,{});const i=r.sales;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Last 7 days"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=i.last7?(0,x.moneyGbp)(i.last7):'\u2014'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.prev7?`The 7 days before: ${(0,x.moneyGbp)(i.prev7)}${null!=i.changePct?` (${i.changePct>=0?'up':'down'} ${Math.abs(i.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.sph7?`Spend per head ${(0,x.moneyGbp)(i.sph7)}`:'Spend per head shows once days have a cash up and Covers'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Takings by week"}),(0,v.jsx)(R,{values:i.weeks.map(e=>e.gross),w:300,h:70}),i.weeks.slice().reverse().map(e=>(0,v.jsx)(E,{a:`${(0,b.ukDate)(e.from)} \u2013 ${(0,b.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up`:'No signed-off cash ups'},e.to)),(0,v.jsx)(l.Muted,{center:!0,children:"Gross takings from signed-off cash ups only, as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,v.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Spend per head",onPress:()=>e('more','spendhead')})]})]})},_e.InsightsStockPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.stock)return(0,v.jsx)(_,{});const i=r.stock;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Low or out now"}),(0,v.jsx)(l.Muted,{center:!0,children:"Live tracked stock (the counts on the Display, Staff and Head Chef apps), at or below each item\u2019s warn-at level."}),i.low.length?i.low.map(e=>(0,v.jsx)(E,{testID:`low-${e.key}`,tone:e.out?w.colours.red:w.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,v.jsx)(l.Muted,{center:!0,children:i.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:`Price rises in the last ${b.RISE_DAYS} days`}),i.rises.length?i.rises.map(e=>(0,v.jsx)(E,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,y.gbp)(e.before)} \u2192 ${(0,y.gbp)(e.after)} a pack \xb7 ${(0,b.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,v.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,v.jsx)(l.Muted,{center:!0,children:i.lastCount?`Last full stock count ${(0,b.ukDate)(i.lastCount)}.`:'No full stock count yet.'})]}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Deliveries, stock & GP",onPress:()=>e('more','kitchencosts')})]})},_e.InsightsGpPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.gp)return(0,v.jsx)(_,{});const i=r.gp;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,v.jsx)(O,{example:r.example}),r.example?(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:w.colours.gold,children:L(i.menu)}),null!=i.startMenu&&null!=i.menu?(0,v.jsx)(l.Muted,{center:!0,children:`${T(i.menu-i.startMenu)} points since ${(0,b.ukDate)(i.trend[0]?.week??'')}`}):null,(0,v.jsx)(R,{values:i.trend.map(e=>e.menu),w:300,h:80})]}):(0,v.jsx)(j.GpOverTime,{rid:s}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),i.drops.length?i.drops.map(e=>(0,v.jsx)(E,{testID:`drop-${e.dishId}`,tone:w.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,b.ukDate)(e.date)}`},e.dishId)):(0,v.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Each dish over 3 months"}),i.dishes.length?i.dishes.map(e=>(0,v.jsx)(E,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const t=S(),o=P(),{list:r,source:i}=C(),[a,c]=(0,s.useState)('all');if(!t.clock)return(0,v.jsx)(_,{});const d='unsigned'===a?r.filter(e=>!1===e.signed):r,u=e=>{const s=new Date(e);return isNaN(s.getTime())?e:s.toLocaleString('en-GB',{day:'2-digit',month:'2-digit',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,v.jsx)(O,{example:!!o}),(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${r.length})`,onPress:()=>c('all'),testID:"clock-filter-all"}),(0,v.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${r.filter(e=>!1===e.signed).length})`,onPress:()=>c('unsigned'),testID:"clock-filter-unsigned"})]}),(0,v.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:d.length?d.map(e=>(0,v.jsxs)(n.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${b.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,b.ukDate)(e.workDate)}. ${e.before?`Before ${e.before}. `:''}${e.after?`After ${e.after}. `:''}By ${e.by}, ${u(e.at)}.${!1===e.signed?' Not signed off yet.':''}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?w.colours.amber:w.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,b.ukDate)(e.workDate)}`}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,children:`${b.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,v.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,v.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,v.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,v.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${b.CLOCK_DAYS} days.`})}),(0,v.jsx)(l.Muted,{center:!0,children:'server'===i?'From the server\u2019s timesheet audit.':'synced'===i?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),o=_r(_d[3]),r=e(o),l=_r(_d[4]),i=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),$=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]);const D='SuperPro';function S(){const{role:e}=(0,k.useCtx)(6e4),s=(0,k.useSignedIn)(),t=(0,k.useInStaffApp)();return(0,b.insightsAccess)({viewRole:e,signed:s,live:(0,$.isLive)(),inStaffApp:t,perm:e=>(0,$.can)(e)})}function P(){return(0,f.useExamples)()&&!(0,$.isLive)()?I.INSIGHTS_SAMPLE:null}function C(){const e=P(),t=(0,u.useOwner)(e=>e.attendance),n=(0,u.useOwner)(e=>e.staff),[o,r]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(e||!(0,$.isLive)())return;let s=!0;return(0,$.readClockChanges)(b.CLOCK_DAYS).then(e=>{s&&e&&r((0,b.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,s.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const s=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:s(o),source:'server'};const r=(0,b.addDaysYmd)((new Date).toISOString().slice(0,10),-b.CLOCK_DAYS);return{list:s((0,b.clockChangesFromAttendance)(t,r)),source:'synced'}},[e,o,t,n])}function M(e){const t=P(),[n,o]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(t||!e||!(0,$.isLive)())return;let s=!0;return(0,$.readLoyaltyInsight)().then(e=>{s&&o(e?(0,b.loyaltyInsight)(e.raw,e.source):null)}),()=>{s=!1}},[t,e]),t?t.loyalty:e&&(0,$.isLive)()?n:null}function N(e,t){const n=P(),o=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,i.useBookings)(e),f=(0,i.useOrders)(e),y=(0,a.useReviews)(e=>e.reviews),x=(0,u.useOwner)(e=>e.attendance),$=(0,k.useHourly)(),w=(0,d.useGpCalcView)(),j=(0,i.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),v=(0,g.useShellStore)((0,p.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,s.useMemo)(()=>{if(n)return{example:!0,...n};const s=j.map(e=>({id:e.id,dish:e.dish,price:e.price})),i=new Date,a=(0,b.salesInsight)(o,l,e,t),c=x.filter(e=>!e.voided&&'confirmed'===(0,u.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,k.paidMins)(e,i).paid,hourly:$[e.staffId]??0}));return{example:!1,sales:a,stock:(0,b.stockInsight)((I??[]).filter(e=>!e.group),v,(s,t)=>(0,h.fmtStockCount)(e,s,t),w.ingredients,Object.values(w.counts??{}),t),gp:(0,b.gpInsight)(w.ingredients,w.cardCosts??{},s,w.settings,Object.values(w.deliveries??{}),t),bookings:(0,b.bookingsInsight)(l,e,t),orders:(0,b.ordersInsight)(f,e,t),reviews:(0,b.reviewsInsight)(y,e,t),labour:(0,b.labourInsight)(c,a.last7,t),salesReport:(0,b.salesReportInsight)(r,e)}},[n,o,r,l,f,y,x,$,e,t,w,j,I,v])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,T=e=>`${e>0?'+':''}${e.toFixed(1)}`;function R({values:e,w:s=220,h:t=44,testID:l}){const i=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(i.length<2)return null;const a=Math.min(...i.map(e=>e.v)),c=Math.max(...i.map(e=>e.v))-a||1,d=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/c*(t-12),g=i[i.length-1];return(0,v.jsx)(n.default,{testID:l,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,v.jsxs)(r.default,{width:s,height:t,children:[(0,v.jsx)(o.Polyline,{points:i.map(e=>`${d(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:w.colours.gold,strokeWidth:2.5,fill:"none"}),(0,v.jsx)(o.Circle,{cx:d(g.i),cy:u(g.v),r:3.5,fill:w.colours.gold})]})})}function G({title:e,big:s,line:n,tone:o,onPress:r,testID:i,children:a,a11y:c,plan:d}){return(0,v.jsxs)(t.default,{testID:i,accessibilityRole:"button",accessibilityLabel:c,accessibilityHint:"Opens the detail",onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??w.colours.gold,backgroundColor:e?w.colours.goldTint:w.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:e}),d?(0,v.jsx)(l.T,{size:11,weight:"semibold",colour:w.colours.goldLight,center:!0,children:d.toUpperCase()}):null,(0,v.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??w.colours.text,children:s}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.muted,children:n}),a,(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.goldLight,children:"Open \u203a"})]})}function O({example:e}){return(0,v.jsxs)(n.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.T,{size:20,weight:"bold",colour:w.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,v.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,v.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function A({title:e,sub:s,children:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.Badge,{kind:"gold",label:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]}),(0,v.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function B({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t),l=C(),i=M(o.loyalty);if(!o.any)return null;const a=(0,b.clockSummary)(l.list),c=(0,b.loyaltyLine)(i),d=s=>e('more',s),u=r.sales,g=r.stock,h=r.gp,p=r.bookings,f=r.orders,$=r.reviews,j=r.labour,I=r.salesReport,P=e=>b.INSIGHT_PLAN[e],B=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=o.sales||o.stock||o.gp||o.clock,E=o.bookings||o.noshows||o.orders||o.loyalty||o.reviews||o.labour||o.salesReports;return(0,v.jsxs)(n.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,v.jsx)(O,{example:r.example}),_?(0,v.jsxs)(A,{testID:"insights-group-superpro",title:D,sub:"Connected EPOS insights",children:[o.sales?(0,v.jsx)(G,{plan:P('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>d('insights-sales'),big:B(u.last7),line:null==u.last7?'No signed-off cash ups in the last 7 days':"Last 7 days"+(null!=u.changePct?` \xb7 ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)}% on the 7 before`:''),a11y:`Sales and takings. ${null!=u.last7?`Last 7 days ${(0,x.moneyGbp)(u.last7)}`:'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,v.jsx)(R,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,o.stock?(0,v.jsx)(G,{plan:P('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>d('insights-stock'),tone:g.low.length?w.colours.amber:void 0,big:g.low.length?`${g.low.length} low`:g.tracked?'None low':'\u2014',line:`${g.low.length?g.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):g.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${g.rises.length} price rise${1===g.rises.length?'':'s'} in ${b.RISE_DAYS} days`,a11y:`Stock. ${g.low.length} tracked items low or out. ${g.rises.length} price rises in ${b.RISE_DAYS} days`}):null,o.gp?(0,v.jsx)(G,{plan:P('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>d('insights-gp'),tone:h.drops.length?w.colours.amber:void 0,big:L(h.menu),line:null==h.menu?'Cost your recipe cards to see GP':`Menu GP${null!=h.startMenu?` \xb7 ${T(h.menu-h.startMenu)} pts in 3 months`:''} \xb7 ${h.drops.length} dish${1===h.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(h.menu)}. ${h.drops.length} dishes fell after a cost change`,children:(0,v.jsx)(R,{testID:"insight-gp-spark",values:h.trend.map(e=>e.menu)})}):null,o.clock?(0,v.jsx)(G,{plan:P('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>d('insights-clock'),tone:a.unsigned?w.colours.amber:void 0,big:String(a.total),line:`Edits in ${b.CLOCK_DAYS} days \xb7 ${a.unsigned} not signed off yet${a.latest?` \xb7 latest by ${a.latest.by}`:''}`,a11y:`Clock-in changes. ${a.total} edits in ${b.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,v.jsxs)(A,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[o.salesReports?(0,v.jsx)(G,{plan:P('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:B(I.gross),line:I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}${I.top.length?` \xb7 ${I.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}, ${B(I.gross)}`:'None yet')}):null,o.bookings?(0,v.jsx)(G,{plan:P('bookings'),testID:"insight-card-bookings",title:"Bookings & Covers",onPress:()=>e('more','bizinsights'),big:String(p.covers7),line:`Covers, last 7 days \xb7 ${p.coversPrev7} the 7 before${null!=p.walkInPct?` \xb7 ${p.walkInPct}% walk-ins`:''}`,a11y:`Bookings and Covers. ${p.covers7} Covers in the last 7 days, ${p.coversPrev7} the 7 before`}):null,o.noshows?(0,v.jsx)(G,{plan:P('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?w.colours.amber:void 0,big:null!=p.noShowPct?`${p.noShowPct}%`:'\u2014',line:`No-shows, 30 days (${p.noShows30}) \xb7 deposits asked ${p.deposits30.asked}, paid ${p.deposits30.paid}${o.sales?` (${(0,y.gbp)(p.deposits30.paidPence)})`:''}${p.deposits30.waived?`, let off ${p.deposits30.waived}`:''}`,a11y:`No-shows and deposits. No-show rate ${p.noShowPct??'not known'} percent over 30 days. ${p.deposits30.paid} of ${p.deposits30.asked} deposits paid`}):null,o.orders?(0,v.jsx)(G,{plan:P('orders'),testID:"insight-card-orders",title:"Orders & takeaway",onPress:()=>e('more','orders'),big:String(f.count7),line:`Orders, last 7 days \xb7 ${f.takeaway7} takeaway, ${f.table7} table \xb7 ${(0,y.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,o.reviews?(0,v.jsx)(G,{plan:P('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:$.low30?w.colours.amber:void 0,big:null!=$.avg30?`${$.avg30.toFixed(1)} \u2605`:'\u2014',line:`${$.count30} review${1===$.count30?'':'s'} in 30 days \xb7 ${$.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${$.avg30??'none'} stars from ${$.count30} reviews in 30 days`}):null,o.loyalty?(0,v.jsx)(G,{plan:P('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:c.big,line:c.line,a11y:`Loyalty. ${i?.members??'Not known'} members. ${i?.stampsMonth??'Not known'} stamps this month. ${i?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,o.labour?(0,v.jsx)(G,{plan:P('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=j.pct7&&j.pct7>35?w.colours.amber:void 0,big:null!=j.pct7?`${j.pct7}%`:'\u2014',line:`Wages of takings, last 7 days \xb7 ${j.paidHours7} signed-off hours${null!=j.labour7?` \xb7 ${B(j.labour7)}`:''}`,a11y:`Wages and hours versus takings. ${j.pct7??'Not known'} percent over 7 days, ${j.paidHours7} hours`}):null]}):null]})}function _(){return(0,v.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function E({a:e,b:s,tone:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]})}},1455,[17,385,85,780,777,858,1233,1006,951,876,942,944,864,1142,851,1456,1458,946,804,1055,1174,1459,8]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1456,[839,1457]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1457,[839]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHT_KEYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"INSIGHT_PLAN",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isHeadChef",{enumerable:!0,get:function(){return a}}),_e.insightsAccess=function(e){if(e.inStaffApp||'owner'!==e.viewRole)return s;if(e.signed){if(a(e.signed))return s;if('owner'!==e.signed.role&&!0!==e.signed.ownerAccess)return s}else if(e.live)return s;const t=t=>!e.live||e.perm(t),n=t('takings.view'),o={sales:n,salesReports:n,gp:n,orders:n,labour:n&&t('wages.view'),stock:t('stock.manage'),clock:t('rota.manage')||t('attendance.view'),bookings:!0,noshows:!0,loyalty:!0,reviews:!0};return{...o,any:r.some(e=>o[e])}},Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return l}}),_e.addDaysYmd=c,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return d}}),_e.salesInsight=function(e,t,r,o){const s={from:c(o,-6),to:o},a={from:c(o,-13),to:c(o,-7)},i=(0,n.takingsInRange)(e,r,s),l=(0,n.takingsInRange)(e,r,a),d=(0,n.spendPerHeadInRange)(e,t,r,s).sph,u=[];for(let t=7;t>=0;t--){const s=c(o,-7*t),a=c(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});u.push({from:a,to:s,gross:i.gross,days:i.days})}const f=null!=i.gross&&null!=l.gross&&l.gross>0?Math.round((i.gross-l.gross)/l.gross*1e3)/10:null;return{last7:i.gross,prev7:l.gross,changePct:f,days7:i.days,sph7:d,weeks:u,empty:u.every(e=>null==e.gross)}},Object.defineProperty(_e,"RISE_DAYS",{enumerable:!0,get:function(){return u}}),_e.stockInsight=function(e,t,n,r,o,s){const a=e.filter(e=>e.active),i=a.map(e=>({i:e,n:t[e.key]??0})).filter(({i:e,n:t})=>t<=e.lowAt).map(({i:e,n:t})=>({key:e.key,name:e.plural||e.name,count:t,lowAt:e.lowAt,out:t<=0,countText:n(e,t),lowText:n(e,e.lowAt)})).sort((e,t)=>e.out===t.out?e.count/Math.max(1,e.lowAt)-t.count/Math.max(1,t.lowAt):e.out?-1:1),l=c(s,-30),d=[];for(const e of r){const t=[...e.prices??[]].filter(e=>e.at).sort((e,t)=>e.at.localeCompare(t.at));if(t.length<2)continue;const n=t[t.length-2],r=t[t.length-1];r.p>n.p&&n.p>0&&r.at.slice(0,10)>=l&&d.push({ingId:e.id,name:e.name,before:n.p,after:r.p,pct:Math.round((r.p-n.p)/n.p*1e3)/10,at:r.at.slice(0,10),supplier:e.supplier})}d.sort((e,t)=>t.pct-e.pct);const u=[...o].sort((e,t)=>t.date.localeCompare(e.date))[0];return{low:i,tracked:a.length,rises:d,lastCount:u?.date??null,empty:!a.length&&!d.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),_e.gpInsight=function(n,r,o,s,a,i){const l=(0,e.menuGp)(n,r,o,s),d=(0,e.gpHistory)(a,l,'3m',i),u=d.points.find(e=>null!=e.menu)?.menu??null,f=l.dishes.map(e=>{const t=d.points.find(t=>null!=t.dishes[e.id])?.dishes[e.id];return{id:e.id,name:e.name,gp:e.gp,target:e.target,change:null!=t?Math.round(10*(e.gp-t))/10:null}}).sort((e,t)=>(e.change??0)-(t.change??0)),g=(0,t.marginDrops)(a,c(i,-14)).filter(e=>o.some(t=>t.id===e.dishId)).map(e=>({dishId:e.dishId,dish:e.dish,before:e.before,after:e.after,drop:Math.round(10*e.drop)/10,date:e.date,supplier:e.supplier}));return{menu:l.menu,startMenu:u,trend:d.points.map(e=>({week:e.week,menu:e.menu})),dishes:f,drops:g,underTarget:l.dishes.filter(e=>e.gp=t&&n.push({id:`${r.id}:reclock`,attendanceId:r.id,staffRef:r.staffId,workDate:r.date,kind:'reclock',after:r.in?m(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return k(n)},_e.clockChangesFromServer=function(e){return k(e.filter(e=>p.has(e.action)||'deleted'===e.action||'reclock'===e.action).map(e=>({id:String(e.id),attendanceId:String(e.attendance_id),staffRef:String(e.staff_ref),staffName:e.staff_name??void 0,workDate:String(e.work_date).slice(0,10),kind:e.action,before:h(e.action,e.old_value),after:h(e.action,e.new_value),by:e.changed_by_name,at:String(e.changed_at),reason:e.reason??void 0,signed:'deleted'===e.action?null:e.signed??null})))},_e.clockSummary=function(e){return{total:e.length,unsigned:e.filter(e=>!1===e.signed).length,people:new Set(e.map(e=>e.staffRef)).size,editors:new Set(e.map(e=>e.by)).size,latest:e[0]??null}},Object.defineProperty(_e,"CLOCK_DAYS",{enumerable:!0,get:function(){return b}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:c(r,-6),to:r},a={from:c(r,-13),to:c(r,-7)},i={from:c(r,-29),to:r},l=(0,n.coversInRange)(o,s),d=(0,n.coversInRange)(o,a),u=(0,n.noShowRate)(o,i,t),f=(0,n.cancelRate)(o,i,t),g=o.filter(e=>{const t=e;return'deposit'===t.security&&!!t.date&&t.date>=i.from&&t.date<=i.to});return{covers7:l.total,coversPrev7:d.total,walkInPct:l.walkInPct,noShowPct:u.rate,noShows30:u.count,cancelPct:f.rate,deposits30:{asked:g.length,paid:g.filter(e=>(e.depositPaid??0)>0).length,paidPence:g.reduce((e,t)=>e+(t.depositPaid??0),0),waived:g.filter(e=>!!e.depositWaived).length}}},_e.ordersInsight=function(e,t,n){const r=c(n,-6),o=e.filter(e=>(!e.restaurantId||e.restaurantId===t)&&e.createdAt&&e.createdAt.slice(0,10)>=r&&e.createdAt.slice(0,10)<=n&&'cancelled'!==e.status);return{count7:o.length,takeaway7:o.filter(e=>'takeaway'===e.type).length,table7:o.filter(e=>'table'===e.type).length,valuePence7:o.reduce((e,t)=>e+(t.subtotal||0),0)}},_e.reviewsInsight=function(e,t,r){const o=e.filter(e=>!e.restaurantId||e.restaurantId===t),s={from:c(r,-29),to:r},a=(0,n.reviewAverage)(o,s);return{avg30:a.avg,count30:a.count,low30:o.filter(e=>e.createdAt.slice(0,10)>=s.from&&e.rating<=2).length}},_e.labourInsight=function(e,t,r){const o={from:c(r,-6),to:r},s=(0,n.labourCostInRange)(e,o),a=e.filter(e=>e.date>=o.from&&e.date<=o.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:s,takings7:t,pct7:(0,n.labourPctOfTakings)(s,t),paidHours7:Math.round(a/6)/10}},_e.salesReportInsight=function(e,t){const n=e.filter(e=>e.rid===t&&e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0];if(!n)return{weekStart:null,gross:null,top:[]};const r='number'==typeof n.vals.gross?n.vals.gross:null;return{weekStart:n.weekStart,gross:r,top:[...n.categories].sort((e,t)=>t.amount-e.amount).slice(0,3)}},_e.loyaltyInsight=function(e,t){if(!e||'object'!=typeof e)return null;const n=w(e.members),r=w(e.stampsMonth),o=w(e.rewardsUsedMonth??e.rewardsMonth),s=w(e.stampsLastMonthToDate??e.stampsLastMonth);if(null==n&&null==r&&null==o)return null;const a=null!=r&&null!=s&&s>0?Math.round((r-s)/s*1e3)/10:null;return{members:n,stampsMonth:r,stampsLastMonth:s,stampsChangePct:a,rewardsMonth:o,source:t}},_e.loyaltyLine=function(e){const t=e=>null==e?'\u2014':String(e);if(!e)return{big:'\u2014',line:'Members \xb7 stamps this month \u2014 \xb7 rewards redeemed this month \u2014'};const n=null==e.stampsLastMonth?'':` (${t(e.stampsLastMonth)} by this date last month${null==e.stampsChangePct?'':`, ${e.stampsChangePct>0?'up':e.stampsChangePct<0?'down':'level'}${e.stampsChangePct?` ${Math.abs(e.stampsChangePct)}%`:''}`})`;return{big:t(e.members),line:`Members \xb7 stamps this month ${t(e.stampsMonth)}${n} \xb7 rewards redeemed this month ${t(e.rewardsMonth)}`}};var e=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]);const r=['sales','salesReports','gp','stock','clock','bookings','noshows','orders','loyalty','reviews','labour'],o={sales:'SuperPro',gp:'SuperPro',stock:'SuperPro',clock:'SuperPro',salesReports:'Pro',bookings:'Pro',noshows:'Pro',orders:'Pro',loyalty:'Pro',reviews:'Pro',labour:'Pro'},s=Object.fromEntries([...r.map(e=>[e,!1]),['any',!1]]),a=e=>/head chef/i.test(e.level??'')||/head chef/i.test(e.job??'');const i=e=>String(e).padStart(2,'0'),l=e=>`${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}`;function c(e,t){const[n,r,o]=e.split('-').map(Number),s=new Date(n,r-1,o);return s.setDate(s.getDate()+t),l(s)}const d=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14;const g={clock_in:'Clock-in changed',clock_out:'Clock-out changed',break:'Break changed',added:'Shift added by hand',voided:'Shift removed from hours',unvoided:'Shift put back in hours',deleted:'Shift deleted',reopened:'Signed-off shift reopened',reclock:'Clocked in again after clocking out',request_applied:'Correction request applied'},p=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),m=e=>{const t=new Date(e);if(isNaN(t.getTime()))return e;try{return t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return`${i(t.getHours())}:${i(t.getMinutes())}`}};function h(e,t){if(null!=t&&''!==t)return'clock_in'!==e&&'clock_out'!==e||!/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(t)?'break'===e&&/^\d+$/.test(t)?`${t} min break`:t:m(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const k=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const b=30;const w=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1458,[954,952,1456]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INSIGHTS_SAMPLE",{enumerable:!0,get:function(){return t}});const t=null},1459,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1460,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1461,804,856,1055,1462,1465,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1461,[1032]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1462,[812,17,362,385,278,85,777,1463,1464,804,1460,1055,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1463,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1464,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1465,[17,385,85,777,860,1464,996,842,1466,1461,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1466,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1467,[813,17,266,347,219,385,85,831,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1468,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1469,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1470,[831]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1471,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1472,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1472,[17,85,777,858,851,946,804,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return ye}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),G=_r(d[22]),M=_r(d[23]),O=_r(d[24]),I=_r(d[25]),B=_r(d[26]),E=_r(d[27]),x=_r(d[28]),D=_r(d[29]),L=_r(d[30]),N=(e=L)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),ge=_r(d[59]),pe=_r(d[60]),he=_r(d[61]),be=_r(d[62]),fe=_r(d[63]);const ye=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},Ce=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:Ce,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>Ce(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:Ce,C:I.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:Ce,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>Ce(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:Ce,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:Ce,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:Ce,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:Ce,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:Ce,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:Ce,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:Ce,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:Ce,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:Ce,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:Ce,C:R.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:Ce,C:A.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:Ce,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:Ce,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:Ce,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:Ce,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:Ce,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:Ce,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:Ce,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:D.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>ye(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:Ce,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:Ce,C:D.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:D.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:Ce,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:Ce,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:Ce,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:Ce,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>N.default.createElement(H.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:_.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:H.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:Q.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:Ce,C:q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:Ce,C:q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:Ce,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:Ce,C:F.DisplaySettingsPage}]);const Se=e=>'owner'===e||'manager'===e;V.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Se,C:V.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Se,C:V.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:U.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:Y.AssistantsPage}]);const ke=e=>'owner'===e||'manager'===e,ve=e=>'owner'===e;(0,y.register)([{id:'superpro-insights',title:'Insights',sub:'Every owner metric in one place: sales, stock, GP, clock-in changes, bookings, orders, reviews, loyalty and wages',group:'Run the day',can:ve,C:G.SuperProInsightsPage},{id:'insights-sales',title:'Insights: Sales',sub:'SuperPro \xb7 takings by week, last 7 days against the 7 before, spend per head',group:'Run the day',can:ve,C:G.InsightsSalesPage},{id:'insights-stock',title:'Insights: Stock',sub:'SuperPro \xb7 low at the last count (par levels) and recent price rises',group:'Run the day',can:ve,C:G.InsightsStockPage},{id:'insights-gp',title:'Insights: GP',sub:'SuperPro \xb7 menu and dish GP over time, and dishes whose GP fell after a cost change',group:'Run the day',can:ve,C:G.InsightsGpPage},{id:'insights-clock',title:'Insights: Clock-in changes',sub:'SuperPro \xb7 who edited which shift, when, before and after, and edits not signed off',group:'Run the day',can:ve,C:G.InsightsClockPage}]);const we=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Pe=e=>ke(e)&&we();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ke,C:W.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Pe,C:W.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Pe,C:W.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Pe,C:W.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:ke,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ke,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:W.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:Ce,C:j.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:Ce,C:j.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:Ce,C:j.Outbox}]);const Re=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:Re,C:$.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:$.optinsAllowed,C:$.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Re,C:K.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Re,C:z.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Re,C:J.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Re,C:X.OrderSheetSettings},...Z.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Re,C:(0,z.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Re,C:ee.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Re,C:te.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:Ce,C:te.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Re,C:te.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Re,C:se.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:Ce,C:ae.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:Ce,C:ae.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:Ce,C:ae.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:Ce,C:ie.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:Ce,C:re.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:Ce,C:ne.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:Ce,C:ue.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ue.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(le.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(de.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ke,C:function(){const{rid:e,today:t}=(0,ce.useCtx)(6e4);return N.default.createElement(de.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(ge.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:Ce,C:oe.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:Ce,C:he.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:Ce,C:be.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:fe.UseOnComputerPage}])},1473,[822,1048,856,1474,876,966,955,816,866,1476,1483,1491,1446,1492,1493,1495,1496,1155,1469,1497,1498,1499,1455,1196,1187,1471,1500,1444,1501,1502,17,1193,1176,1445,1433,1447,1485,1507,1508,1454,1509,1436,1421,1510,1451,1511,886,1512,1513,1515,1182,1460,1516,1382,1462,1528,1079,1055,1197,1149,1531,1534,1537,1540]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1474,[17,378,219,385,85,19,777,1024,1327,876,804,1475,1184,1470,1055,8,260]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1475,[831]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1476,[812,1442,17,851,85,777,876,804,1055,884,885,1477,946,962,1029,1440,1478,1479,1481,994,1482,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1477,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1478,[812,17,85,777,804,876,1343,1342,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1479,[17,85,777,1480,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1480,[831,892,946,880]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1481,[17,85,777,804,960,1020,946,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1482,[892,946]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1483,[17,85,777,835,876,1484,804,1055,1485,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1484,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1485,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1486,1490,804,1055,1069,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1486,[1487,1489,1488]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1487,[843,1488]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1488,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1489,[1487,891]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1490,[869,824,831,834]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1491,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1492,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1493,[1037,17,85,1494,814,857,777,876,804,1055,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1494,[812,17,219,385,85,780,814,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1495,[17,1151,847,1055,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1496,[17,1030,1055,946,961,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1497,[17,1388,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1498,[17,85,780,777,858,1006,1457,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1499,[17,85,1336,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1500,[17,776,1055,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1501,[17,85,777,858,1006,876,1053,1456,946,804,1232,1233,1055,8]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1502,[805,1408,812,822,843,1503,1427,1475,1218,841,1254,946,1504,1506,1428,17,1096,1483,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1503,[843,17,85,777,845,851,1150,858,853,804,8]); +__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1504,[946,17,264,219,85,1272,777,1251,1254,804,1505,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1505,[17,219,85,777,1251,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1506,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1507,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1508,[17,85,777,946,863,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1509,[813,812,822,17,219,385,85,777,1220,858,1490,848,1222,1016,804,1025,1055,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1510,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1511,[17,385,85,777,876,998,851,999,804,840,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1512,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1513,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1514,804,880,1157,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1514,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1515,[17,85,777,804,1423,1503,1055,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1516,[812,1031,779,17,385,85,777,876,1467,1517,1518,1519,804,1055,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1517,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1518,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1519,[1520,1098,843,1521,1522,876,858,996,1467,1517,1518,1524,1523,1526,1527,994,995]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1520,[1062,1061,1021]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1521,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1522,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1523,1521]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1523,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1524,1525]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1524,[824,831,834]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1525,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1526,[816,876,956,851,1523,1015,1069]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1527,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1528,[17,362,85,777,804,1463,1524,1475,1525,1352,890,1529,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1529,[17,85,777,804,1530,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1530,[824,831,834]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1531,[17,779,85,777,845,1251,1532,1533,804,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1532,[845]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1533,[946,1532,1254]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1534,[17,85,777,858,1006,1535,938,839,1536,1018,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1535,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1536,[839,1007,1457]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1537,[812,17,85,777,1538,1019,804,1539,1055,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1538,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1539,[1018,1019,935,892,946]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1540,[17,264,219,85,777,812,804,946,1418,1182,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1541,[219]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1543,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1544,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1467,1084,1082,1222,1235,938,876,1030,1475,880,946,804,1327,1545,1055,1485,1407,1155,1469,1471,1460,1446,1473,1541,1543,1551,1552,1553,1556,1559,8]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1545,[17,266,347,219,385,278,85,409,780,779,1327,1446,1473,1407,1155,1471,1469,1055,1024,777,858,876,863,946,880,804,1546,1547,1548,1549,1550,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1546,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1547,[17,780,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1548,[17,85,777,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1549,[17,385,1157,1158,816,805,777,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1550,[17,219]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=h,e.buttonsFor=function(s){return o.filter(t=>h(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),h=Math.floor(Math.max(88,(t-72-64-36)/i)),c=t>=1e3?15:13,k=Math.round(1.4*c),b=Math.max(48,Math.min(72,h-2*k-14,l-34));return{panelW:n,colW:l,per:h,circle:b,label:c,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return c}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}],last:[{id:'superpro-insights',label:'Insights',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function h(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const c=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1551,[1546]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1552,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1553,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1554,1543,1552,1555,8]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1554,[17,385,278,85,777,804,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1555,[17,85,780,777,804,1554,1552,8]); +__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1556,[17,264,385,85,780,777,858,876,1557,961,1208,1453,804,1547,1055,1554,1558,1552,1555,1553,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1557,[831,834,824]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1558,[961]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1559,[17,85,777,804,1560,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1560,[]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1561,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1467,1085,1084,1082,1475,1222,880,804,1485,1407,1155,1055,1420,1469,1460,1471,1446,1473,1562,1541,1564,1566,1568,1565,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1562,[17,278,85,1494,857,777,876,814,1447,804,1563,1564,1565,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1563,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1564,[17]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1565,[17,85,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1566,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1563,1564,1565,1567,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1567,[876]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1568,[17,85,777,876,1058,804,1563,1564,1565,1049,1567,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1569,[13,17,856,1570,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1570,[1447,1571,813,958,1070,1503,1202,1203,1026,1023,1024,1504,1531,1506,1149,938,979,1572,976,880,1029,1030,1481,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1497,1492,1513,1573,1415,966,219,1237,1176,1182,1445,1196,1193,1468,1179,878,1205,1206,884,776,946,8]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1571,[17,85,777,1055,946,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1572,[219,977]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1573,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1574,[13,17,856,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1575,[1440,946,778,1401,1576,993,13,1603,479,17,368,319,219,24,85,805,857,1063,856,1605,19,858,996,876,804,1415,966,987,1606,1607,1026,1608,1102,880,1006,960,1611,1372,8,1612,1613,1614,1615]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1576,[1577,1600,1602]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1577,[198,1578,1581,1595,1596,1597,1598,1599]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1578,[198,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1579,[1580]); +__d(function(g,r,i,a,m,e,d){},1580,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1581,[1582,198,1578,1595,1596]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1582,[1583,1584,1594]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1583,[1584,1588,1593]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1584,[198,355,1585,1589,1590,1591,1592,1588,1593]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1585,[198,1586,322,263,1587,1588]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1586,[487]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1587,[198,322]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1588,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1589,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1590,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1591,[1589]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1592,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1593,[355,1587]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1594,[17,1584]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1595,[1582,198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1596,[1582,1595]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1597,[1578]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1598,[198,1578,1581,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1599,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1600,[198,37,1601]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1601,[198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1602,[17,1577]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1603,[1604]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1604,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1605,[17,24,85,409,777,857,966,946,880,805,804,1546,1548,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1606,[951,868,867,946]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1607,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1608,[805,779,812,17,368,266,347,363,219,385,278,409,85,1485,1351,880,780,1055,878,876,777,804,1519,891,1609,1517,1518,1475,1352,1530,890,1610,1527,8,260]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1609,[876,816,996]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1610,[831]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1611,[]); +__d(function(e,o,s,p,t,n,a){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1612,[]); +__d(function(o,e,s,p,t,c,d){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1613,[]); +__d(function(o,e,s,p,t,d,f){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1614,[]); +__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1615,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1616,[13,17,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1617,[1618]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1618,[8,1619,574]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1619,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1620,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1621,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/owner-app/admin.html b/owner-app/admin.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/admin.html +++ b/owner-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer.html b/owner-app/customer.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer.html +++ b/owner-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage.html b/owner-app/customer/anchorage.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage.html +++ b/owner-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/book.html b/owner-app/customer/anchorage/book.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/book.html +++ b/owner-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/feedback.html b/owner-app/customer/anchorage/feedback.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/feedback.html +++ b/owner-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/gift.html b/owner-app/customer/anchorage/gift.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/gift.html +++ b/owner-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/lost.html b/owner-app/customer/anchorage/lost.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/lost.html +++ b/owner-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/loyalty.html b/owner-app/customer/anchorage/loyalty.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/loyalty.html +++ b/owner-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/merch.html b/owner-app/customer/anchorage/merch.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/merch.html +++ b/owner-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/offers.html b/owner-app/customer/anchorage/offers.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/offers.html +++ b/owner-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/refer.html b/owner-app/customer/anchorage/refer.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/refer.html +++ b/owner-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/waitlist.html b/owner-app/customer/anchorage/waitlist.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/waitlist.html +++ b/owner-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/whatson.html b/owner-app/customer/anchorage/whatson.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/anchorage/whatson.html +++ b/owner-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/basket.html b/owner-app/customer/basket.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/basket.html +++ b/owner-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/profile.html b/owner-app/customer/profile.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/customer/profile.html +++ b/owner-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/demo.html b/owner-app/demo.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/demo.html +++ b/owner-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/display.html b/owner-app/display.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/display.html +++ b/owner-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/index.html b/owner-app/index.html index 3f7e15a9291feb6b42ceba28f00907c6f1a18648..420e9e3725eaa648b25dcde032927e7f8ccfb12b 100644 --- a/owner-app/index.html +++ b/owner-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/kitchen.html b/owner-app/kitchen.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/kitchen.html +++ b/owner-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/owner.html b/owner-app/owner.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/owner.html +++ b/owner-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/staff.html b/owner-app/staff.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/staff.html +++ b/owner-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/sw.js b/owner-app/sw.js index 16ec69f5716687bea85bf96969a314fbd8b8d97a..03ec55ed6c858eb5a8f1c24807d77998e1826470 100644 --- a/owner-app/sw.js +++ b/owner-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Manager service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-owner-0c0491e070"; +const V = "cc-owner-2ad011aaba"; const BASE = "/owner-app/"; -const PRECACHE = ["/owner-app/apple-touch-icon.png", "/owner-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-app/brand-logo.png", "/owner-app/favicon.ico", "/owner-app/icon-192.png", "/owner-app/icon-512.png", "/owner-app/icon-maskable-192.png", "/owner-app/icon-maskable-512.png", "/owner-app/manifest.webmanifest", "/owner-app/index.html", "/owner-app/_expo/static/js/web/bundle.js?v=0c0491e07035d7e73713c555ee209544f28b89b630f68919464c9a82f99c378f"]; +const PRECACHE = ["/owner-app/apple-touch-icon.png", "/owner-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-app/brand-logo.png", "/owner-app/favicon.ico", "/owner-app/icon-192.png", "/owner-app/icon-512.png", "/owner-app/icon-maskable-192.png", "/owner-app/icon-maskable-512.png", "/owner-app/manifest.webmanifest", "/owner-app/index.html", "/owner-app/_expo/static/js/web/bundle.js?v=2ad011aaba3bdee4ed396277b069c8ac0158a13009d202d116d51dbfeccc3f2d"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/owner-app/team.html b/owner-app/team.html index 5bbe3080f4deb8dc911196bdf15e9a5e50cd569a..8a0ab060e54382dd3b2ac7bf230b30e94b90731f 100644 --- a/owner-app/team.html +++ b/owner-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/_expo/static/js/web/bundle.js b/owner-desktop/_expo/static/js/web/bundle.js index 5ca46234de6980e3121a1902aa4e5d209683b3f0..420ead5777f5411b65dee551bcc68a3acb1663be 100644 --- a/owner-desktop/_expo/static/js/web/bundle.js +++ b/owner-desktop/_expo/static/js/web/bundle.js @@ -6,11 +6,11 @@ var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow() __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},0,[1,2]); __d(function(g,r,i,a,m,e,d){},1,[]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0])},2,[3]); -__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1618]); +__d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},3,[4,7,1621]); __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},4,[5,6]); __d(function(g,r,i,a,m,e,d){},5,[]); __d(function(g,r,i,a,m,e,d){const _='undefined'==typeof window;globalThis.__webpack_chunk_load__=_=>g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},6,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1614,1617]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},7,[8,10,17,692,1617,1620]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},8,[9]); __d(function(g,r,i,a,m,e,d){ /** @@ -24,7 +24,7 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},9,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},10,[11]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1566,1571,1572,1613]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},11,[12,1021,1238,1239,1244,1246,1248,1255,1307,1308,1309,1310,1311,1312,1314,1315,1316,1317,1320,1321,1322,1323,1326,1402,1403,1404,1569,1574,1575,1616]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var t=r(d[0]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},12,[13,17,775,856,955,8]); __d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return Object.keys(t).forEach(function(c){"default"===c||Object.prototype.hasOwnProperty.call(n,c)||Object.defineProperty(n,c,{enumerable:!0,get:function(){return t[c]}})}),t}Object.defineProperty(e,"__esModule",{value:!0}),r(d[0]),t(r(d[1]),e),t(r(d[2]),e),t(r(d[3]),e),t(r(d[4]),e)},13,[14,15,765,766,768]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},14,[]); @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); @@ -1485,8 +1485,8 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1403,[13,17,856,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1404,[13,17,1405,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1542,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1455,1462,1463,1464,1184,1237,1465,1446,1466,1468,1444,1155,1480,1220,1382,1222,1235,1470,1082,1084,1538,1539,1558,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1405,[17,856,1406,1545,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canSignOffHours",{enumerable:!0,get:function(){return ue}}),_e.barTabsFor=fe,_e.signOffSpeech=ge,_e.OwnerApp=function(){return M.IS_OWNER_DESKTOP?(0,le.jsx)(ae.DesktopGate,{phone:(0,le.jsx)(me,{})}):(0,ne.isDesktop)()?(0,le.jsx)(ie.DesktopShell,{}):(0,le.jsx)(me,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),w=e(_r(d[14])),j=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=_r(d[20]),C=_r(d[21]),v=_r(d[22]),I=_r(d[23]),L=_r(d[24]),O=_r(d[25]),T=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]);_r(d[32]);var $=_r(d[33]),D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),F=_r(d[39]),U=_r(d[40]),z=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]);_r(d[45]);var Y=_r(d[46]),J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]);const de=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ce=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],ue=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function fe(e,t){return'owner'===e||'manager'===e||t?[{id:'home',label:'Home',icon:'home'},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'rota',label:'Rota',icon:'rota'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'more',label:'More',icon:'more'}]:ce.filter(t=>!t.can||t.can(e)).map(e=>e)}function ge(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const he={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function me(){const{rid:e,r:ne,role:ae,today:ie,now:ue,meId:me,me:be}=(0,B.useCtx)(3e4);(0,b.useTipsPosted)(e,ie,'staff'!==ae);const pe=(0,B.useSignedIn)();(0,u.useSoldOutLink)(!0,(pe?.name??be).replace(' (example)',''));const xe=(0,I.useOrders)(e),[we,je]=(0,x.useState)('home'),[Se,ye]=(0,x.useState)(null),[Ae,ke]=(0,x.useState)(!1),Re=(0,n.useLiveVenue)(),[Ce,ve]=(0,x.useState)(!1),Ie=(0,x.useRef)(null);(0,x.useEffect)(()=>{(0,B.ensureAttendance)(ie,ue),(0,J.ensureChat)(ue)},[ie]),globalThis.__ccNow=ue.getTime();const Le=(0,J.useChatUnread)().total,Oe=(0,x.useRef)({t:'home',s:null});Oe.current={t:we,s:Se};const Te=(0,x.useRef)([]),Ee=(0,c.useScrollMemory)(Ie),Be=(0,x.useCallback)((e,t=null)=>{'chat'!==e||'owner'!==ae&&'manager'!==ae||(e='more',t='chat');const s=Oe.current;s.t===e&&s.s===t||(Te.current=[...Te.current,{...s,y:Ee.leave()}].slice(-30),Ee.restore(0)),je(e),ye(t)},[ae]),Pe=(0,x.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Oe.current;let t=Te.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Te.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return Ee.leave(),je(s.t),ye(s.s),Ee.restore(s.y??0),!0},[]);(0,f.useWebBack)(Pe);const Ne=(0,f.useInnerBackShown)();(0,x.useEffect)(()=>(se.useVoiceNav.setState({go:Be}),()=>se.useVoiceNav.setState({go:null})),[Be]),(0,x.useEffect)(()=>{h.PITCH&&(globalThis.__pitchGo=Be,globalThis.__pitchOwner=L.useOwner)},[Be]),(0,x.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Pe);return()=>e.remove()},[Pe]),(0,x.useEffect)(()=>{const e=ce.find(e=>e.id===we);e?.can&&!e.can(ae)&&Be('home');const t=(0,G.pageFor)(Se);t?.can&&!t.can(ae)&&ye(null)},[ae]);const $e='more'===we?(0,G.pageFor)(Se):void 0,De=xe.filter(e=>(0,E.LIVE)(e)&&'new'===e.status).length,{unread:Me,list:He,read:We}=(0,Y.useNotifications)();(0,ee.useAlertWatcher)(e,{nag:'staff'!==ae}),(0,te.useReviewAlerts)(e),(0,oe.useScheduledNotices)({rid:e,staffId:pe?.id??'',name:be,onOpen:e=>'bookings'===e?Be('bookings'):'chat'===e?Be('chat'):Be('more',e)}),(0,re.useOffRotaAlerts)({enabled:'staff'!==ae&&!!pe});const Ve=pe?.role??ae,Fe='owner'===Ve?'OWNER':'manager'===Ve?'MANAGER':'STAFF',Ue=(0,ee.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,ee.isUnread)(t,s)&&!(0,ee.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),ze=(0,ee.useAlerts)(t=>t.todoSeen[e]),qe=Math.max(0,Me-He.filter(e=>!We[e.id]&&(ze??[]).includes(e.id)).length)+Ue;(0,ee.useAlertSeenSync)(e),(0,x.useEffect)(()=>{q.useShellBadges.setState({notifCount:qe})},[qe]);const Ge=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Ke=L.CAN.manage(ae),Ye=(0,r.useOutstanding)(),Je=Ye.days.length+Ye.requests,Qe=fe(ae,Ke),Xe='more'===we&&'signoff'===Se?'signoff':'more'===we&&'rota'===Se?'rota':'more'===we&&'cashup'===Se?'cashup':'forecast'===we||'orders'===we&&Ke||'chat'===we&&Ke?'more':we,Ze=t.IS_ISOLATED_VENUE?[{id:e,name:ne.name,place:ne.location||ne.address||''}]:de,et=Ze.find(t=>t.id===e)??Ze[0],tt=pe?.ownerAccess&&'owner'!==pe.role?'owner privileges':pe?.managerAccess&&'staff'===pe.role?'manager privileges':'',st=(0,D.ownerHomeLayout)(ae,pe);(0,A.default)().width;return(0,le.jsxs)(R.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,le.jsxs)(k.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,le.jsxs)(k.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>Be('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,le.jsx)(S.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:qe?`Notifications, ${qe} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>Be('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,le.jsxs)(k.default,{children:[(0,le.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),qe?(0,le.jsx)(k.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,le.jsx)(C.T,{size:10,weight:"bold",children:qe})}):null]})})]}),(0,le.jsx)(k.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,le.jsx)(k.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,le.jsx)(S.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${be}. Account and role${tt?`, ${tt}`:''}`,disabled:'owner'!==M.APP_VARIANT,onPress:()=>ve(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,le.jsxs)(C.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,le.jsx)(_.StaffAvatar,{id:me,size:24,ring:!1}),(0,le.jsxs)(k.default,{style:{flexShrink:1},children:[(0,le.jsxs)(C.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[pe?`${be} \xb7 ${pe.level??L.ROLE_LABEL[pe.role]}`:`${be} \xb7 ${L.ROLE_LABEL[ae]}`,'owner'===M.APP_VARIANT?' \u25be':'']}),tt?(0,le.jsx)(C.Muted,{center:!1,size:10,numberOfLines:1,children:tt}):null]})]})})})}),(0,le.jsx)(S.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>ke(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,le.jsx)(v.VenueHeaderBlock,{rid:e,name:ne.name,badge:Fe,place:`${'staff'===ae?'Staff preview \xb7 ':'Managers \xb7 '}${et.place}`})}),ae!==(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner')&&'owner'===M.APP_VARIANT?(0,le.jsx)(S.default,{onPress:()=>L.useOwner.getState().setPreviewRole(pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,le.jsx)(C.T,{size:12,colour:O.colours.gold,children:'staff'===ae?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[ae].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[pe?.ownerAccess?'owner':pe?.managerAccess?'manager':pe?.role??'owner']}.`})}):null]}),(0,le.jsxs)(y.default,{ref:Ie,...Ee.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'!==we||Se?null:(0,le.jsx)(l.AlertsBanner,{}),'home'!==we||Se?null:(0,le.jsx)(a.WhosOnShift,{}),(0,le.jsx)(f.BackTitleRow,{back:!('home'===we&&!Se||Ne),onBack:Pe,title:$e?$e.title:'bookings'===we&&'waitlist'===Se?'Waitlist':'staff'===ae&&'home'===we?'Staff app preview':he[we]}),'home'===we&&pe&&'staff'===pe.role&&'owner'===M.APP_VARIANT?(0,le.jsxs)(k.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,le.jsx)(C.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,le.jsx)(C.Button,{label:"Clock in and my shifts",onPress:()=>Be('more','clock')})]}):null,'home'===we?'staff'===ae?(0,le.jsx)(V.StaffHome,{go:Be}):(0,le.jsx)($.Dashboard,{go:Be,ownerHome:st}):null,'orders'===we?(0,le.jsx)(K.Orders,{}):null,'bookings'===we?(0,le.jsx)(T.Bookings,{go:Be,only:'waitlist'===Se?'waitlist':void 0}):null,'forecast'===we?(0,le.jsx)(F.Forecasts,{go:Be}):null,'chat'===we?(0,le.jsx)(J.Chat,{go:Be}):null,'more'===we?$e?(0,le.jsx)($e.C,{go:Be}):(0,le.jsx)(G.MoreMenu,{go:Be}):null]}),(0,le.jsx)(p.SeatAllergenReminder,{rid:e}),'staff'!==ae?(0,le.jsx)(Z.PrintHost,{rid:e}):null,'staff'!==ae?(0,le.jsx)(X.AlertHost,{variant:"managers",rid:e,me:be,onOpen:e=>Be('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,le.jsx)(Q.AssistantSheet,{}),(0,le.jsx)(z.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:Xe,onPress:e=>'signoff'===e?Be('more','signoff'):'rota'===e?Be('more','rota'):'cashup'===e?Be('more','cashup'):Be(e),tabs:Qe.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?ge(Ye.days.length,Ye.requests):'cashup'===e.id?'Cash up':'more'===e.id&&Ke&&De?`More, ${De} new order${De>1?'s':''} in Orders`:'more'===e.id&&Ke&&Le?`More, ${Le} unread in Staff chat`:void 0,badge:'chat'===e.id&&Le?{text:String(Le),bg:O.colours.red}:'bookings'===e.id&&Ge?{text:String(Ge),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&De?{text:String(De),bg:O.colours.red}:'signoff'===e.id&&Je?{text:String(Je),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Ke&&De?{text:String(De),bg:O.colours.red,testID:'more-orders-badge'}:'more'===e.id&&Ke&&Le?{text:String(Le),bg:O.colours.red,testID:'more-chat-badge'}:null}))}),(0,le.jsx)(j.default,{visible:Ae,transparent:!0,animationType:"fade",onRequestClose:()=>ke(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ke(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Your venues"}),Ze.filter(e=>!Re||'saltmarsh'!==e.id).map(t=>(0,le.jsx)(S.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),ke(!1),Be('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,le.jsxs)(C.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(k.default,{children:[(0,le.jsx)(C.T,{weight:"medium",children:t.name}),(0,le.jsx)(C.Muted,{children:t.place})]}),t.id===e?(0,le.jsx)(C.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,le.jsx)(C.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${ne.name}.`:Re?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,le.jsx)(j.default,{visible:Ce,transparent:!0,animationType:"fade",onRequestClose:()=>ve(!1),children:(0,le.jsx)(S.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>ve(!1),children:(0,le.jsxs)(k.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[pe?(0,le.jsxs)(C.Row,{gap:10,children:[(0,le.jsx)(_.StaffAvatar,{id:pe.id,size:44}),(0,le.jsxs)(k.default,{style:{flex:1},children:[(0,le.jsxs)(C.T,{weight:"semibold",children:["Signed in as ",pe.name]}),(0,le.jsx)(C.Muted,{children:(0,N.levelJob)(pe.level??L.ROLE_LABEL[pe.role],pe.job)})]})]}):(0,le.jsxs)(k.default,{style:{gap:6},children:[(0,le.jsx)(C.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,le.jsx)(C.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,le.jsx)(P.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!pe?null:(0,le.jsx)(C.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,N.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,le.jsx)(C.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!pe||(0,B.clampRole)(e,pe.ownerAccess?'owner':pe.managerAccess?'manager':pe.role)===e).map(e=>(0,le.jsx)(C.Button,{kind:e===ae?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),ve(!1)}},e))]})})}),(0,le.jsx)(H.OnboardingHost,{go:Be}),(0,le.jsx)(W.CoachHost,{})]})}},1406,[805,813,946,1187,1218,1203,1026,1023,938,1024,880,1030,1085,17,356,378,385,278,409,85,19,777,857,858,876,804,1407,1178,1055,884,1415,966,219,1420,839,856,1460,1467,1468,1469,1184,1237,1470,1446,1471,1473,1444,1155,1485,1220,1382,1222,1235,1475,1082,1084,1541,1542,1561,8]); __d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:O}={}){const{rid:ne,r:ie,now:ae,today:oe,me:de,role:re}=(0,w.useCtx)(1e4),ue=(0,_.useBookings)(ne),ce=(0,w.useInStaffApp)(),he=(0,w.useShiftManager)(),ge=(0,_.useWaitlist)(ne),[be,pe]=((0,_.useStore)(e=>e.alertAcks),(0,P.useState)(oe)),ke=(0,U.useFrontDoor)(be),xe=(0,y.useBookingWrite)(),me=(0,f.useSeatClearFinish)(),[we,ye]=(0,P.useState)(''),[je,fe]=(0,P.useState)(!1),[Ie,Be]=(0,P.useState)(2),De=bee.date===be).sort((e,s)=>e.time.localeCompare(s.time)),$e=ge.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),Te=Se.filter(e=>'noshow'===e.status),Ce=(0,Z.useSync)(e=>!!e.venueId&&'guest'!==e.kind),Le=Se.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),ve=(0,p.cancelledDayTally)(ue,be),Ne=(0,p.cancelledTallyWords)(ve,be===oe?'today':'that day'),Pe=Se.filter(e=>!e.walkIn),Oe=Se.filter(e=>e.walkIn),We=ue.filter(e=>'pending'===e.status&&e.date>=oe).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Me,Ee]=(0,P.useState)(null),Ae=(0,z.parseYmd)(be);Ae.setHours(12);const Re=(0,te.hoursFor)(ie,Ae),ze=Re?.open??new Date(`${be}T12:00:00`),He=Re?.close??new Date(`${be}T21:00:00`),Ge=Re||Se.length?De?'No one seated that day':be===oe?'No bookings yet today':'No bookings yet':be===oe?'Closed today':'Closed that day',Fe=$e.length>0||je||'waitlist'===O?(0,le.jsxs)(W.default,{style:{gap:10},children:[(0,le.jsx)(F.SectionHead,{title:`Waitlist (${$e.length})`,sub:`New party waits about ${(0,H.estimateWait)($e.length+1,ie.settings.turnMins,1)} min (estimate)`}),$e.map((e,s)=>(0,le.jsxs)(W.default,{style:M.styles.card,children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,le.jsxs)(M.Muted,{children:[(0,z.minsBetween)(new Date(e.joinedAt),ae)," min \xb7 est. ",(0,H.estimateWait)(s+1,ie.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,le.jsx)(M.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,le.jsxs)(M.Row,{gap:6,children:['waiting'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>_.repo.waitlist.setStatus(e.id,'notified')}):null,me.ok?(0,le.jsx)(M.Button,{small:!0,label:"Seat",onPress:()=>_.repo.waitlist.setStatus(e.id,'seated')}):null,(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>_.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:we,onChangeText:ye,style:[M.styles.input,{flex:1}]}),(0,le.jsx)(M.Stepper,{value:Ie,onChange:Be,min:1,max:12,label:"party"})]}),(0,le.jsx)(M.Button,{kind:"secondary",label:"Add to waitlist",disabled:we.trim().length<2,onPress:()=>{_.repo.waitlist.join(ne,we.trim(),Ie),ye('')}})]}):(0,le.jsx)(M.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>fe(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===O?(0,le.jsx)(W.default,{style:{gap:12},testID:"bookings-waitlist-only",children:Fe}):(0,le.jsxs)(W.default,{style:{gap:12},children:[(0,le.jsx)(l.BookingSaveBanner,{rid:ne}),e&&!ce&&'staff'!==re?(0,le.jsx)(M.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===ne)&&!ce&&'staff'!==re?(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"table"}):null,!s.IS_WILDINGS&&!ie.settings.hotel?.enabled||ce||'staff'===re?null:(0,le.jsx)(i.VenueRequestList,{rid:ne,kind:"room",hotel:ie.settings.hotel??n.WILDINGS_HOTEL}),(0,le.jsx)(q.BookingsDayNav,{today:oe,date:be,onDate:pe,count:e=>ue.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=ue.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,le.jsx)(W.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,le.jsx)(se.DayGraph,{bare:!0,fill:!0,todays:Se,open:ze,close:He,now:ae,turnBase:ie.settings.turnMins,height:128,past:De,closed:!Re,emptyText:Ge})}),De?(0,le.jsxs)(W.default,{testID:"bookings-past-totals",style:[M.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,q.longDay)(be)}: ${Pe.length} tables, ${Le} Covers, ${Se.filter(e=>'finished'===e.status).length} finished, ${Te.length} no-shows, ${Se.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,le.jsxs)(M.T,{size:17,weight:"semibold",children:["That day: ",Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']}),(0,le.jsxs)(M.T,{size:16,colour:G.colours.text,children:[Se.filter(e=>'finished'===e.status).length," finished \xb7 ",Te.length," no-show",1===Te.length?'':'s'," \xb7 ",Se.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,le.jsx)(M.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,le.jsx)(W.default,{testID:"bookings-summary",children:(0,le.jsxs)(M.T,{weight:"semibold",children:[Pe.length," booking",1===Pe.length?'':'s',Oe.length?` \xb7 ${Oe.length} walk-in${1===Oe.length?'':'s'}`:''," \xb7 ",Le," ",1===Le?'Cover':'Covers']})}),ce||'staff'===re||De?null:(0,le.jsx)(h.BookingsMatchStatus,{}),(0,le.jsx)(W.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ne,style:{alignItems:'center'},children:(0,le.jsx)(M.T,{size:15,colour:G.colours.muted,center:!0,children:Ne})}),(0,le.jsxs)(W.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[De||ce&&!he?null:(0,le.jsx)(T.QuietButton,{label:"New booking",onPress:ke.openBooking,testID:"add-booking",disabled:!xe.ok,accessibilityHint:xe.hint}),ce&&he&&be===oe?(0,le.jsx)(T.QuietButton,{label:"Walk-in",onPress:ke.openWalkIn,testID:"add-walkin",disabled:!xe.ok,accessibilityHint:xe.hint}):null,be===oe?(0,le.jsx)(C.CloseGardenButton,{quiet:!0,short:!0,rid:ne,r:ie,now:ae,by:de}):null]}),We.length?(0,le.jsxs)(W.default,{testID:"pending-requests",style:[M.styles.card,{borderColor:G.colours.amber,gap:8}],children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:G.colours.amber,children:["Needs confirming (",We.length,")"]}),(0,le.jsx)(M.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),We.map(e=>(0,le.jsxs)(W.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:G.colours.border},children:[(0,le.jsxs)(M.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,le.jsxs)(M.Muted,{children:[(0,z.niceDate)((0,z.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,le.jsxs)(M.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie}),'staff'!==re&&((0,v.needsHoldOk)(e)||e.date===oe&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,v.needsHoldOk)(e)?(0,le.jsx)(M.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,L.confirmHolds)(e.id,de)}):null,e.holdOk&&'seated'===e.status?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,L.serveHolds)(e,de,'owner')}):null]}):null,Me===e.id?(0,le.jsxs)(W.default,{style:{gap:6},children:[(0,le.jsxs)(M.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{_.repo.bookings.decide(e.id,'declined',de),Ee(null)}}),(0,le.jsx)(M.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Ee(null)})]})]}):xe.ok?(0,le.jsxs)(M.Row,{gap:6,children:[(0,le.jsx)(M.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>_.repo.bookings.decide(e.id,'confirmed',de)}),(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Ee(e.id)}),(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"change"})]}):(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),(0,le.jsx)(J.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Se.length?(0,le.jsx)(M.Muted,{children:"No bookings for this day yet."}):null,Se.map(e=>{const s='confirmed'===e.status&&be===oe&&(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)>15,t=(0,B.depositState)(e),n=(0,B.depositBadge)(e,R.gbp);return(0,le.jsxs)(W.default,{testID:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[M.styles.card,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,N.seatedHighlightStyle)({borderColor:(0,v.hasAllergens)(e)?G.colours.red:G.colours.goldLight}):{borderColor:(0,v.hasAllergens)(e)?G.colours.red:s?G.colours.amber:G.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,le.jsx)(L.AllergenBar,{b:e}),(0,le.jsx)(l.BookingNotSavedLine,{b:e}),(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(M.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,le.jsxs)(M.T,{weight:"semibold",colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?N.SEATED_FG:G.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,v.hasAllergens)(e)?(0,le.jsx)(E.AllergyIcon,{text:(0,v.allergenText)(e),size:20,colour:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?'#7A4A00':G.colours.amber,ink:(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?G.colours.gold:G.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,le.jsx)(M.Badge,{kind:'seated'===(0,v.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,v.shownStatus)(e)[0].toUpperCase()+(0,v.shownStatus)(e).slice(1)})]}),n?(0,le.jsx)(I.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,N.isSeatedHighlight)((0,v.shownStatus)(e))?(0,le.jsxs)(M.T,{size:14,colour:N.SEATED_MUTED,children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,le.jsxs)(M.Muted,{children:[e.table?(0,V.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,le.jsxs)(M.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,le.jsx)(M.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,le.jsx)(L.NeedsPills,{b:e,r:ie,only:"rules"}),(0,b.historyLines)(e)[0]?(0,le.jsxs)(M.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,le.jsxs)(M.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[De||!(0,B.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>_.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:de,depositPaidAt:(new Date).toISOString()})}),De?null:(0,le.jsx)(S.WixDepositLink,{b:e,rid:ne}),De||!xe.ok||ce&&!he?null:(0,le.jsx)(D.WaiveDepositButton,{b:e,who:de,small:!0}),'waived'===t&&e.depositWaived?(0,le.jsx)(M.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,B.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,le.jsx)(M.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,le.jsxs)(M.Muted,{children:[(0,X.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,le.jsx)(M.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,le.jsx)(M.Badge,{kind:"red",label:`${(0,A.allergenLabel)(e.allergen)} \xb7 ${(0,A.severityLabel)(e.severity)}`},e.allergen))}):null,(0,v.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,le.jsx)(Q.BookingAllergyChain,{b:e,me:de}):null,e.walkIn?null:(0,le.jsx)(J.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,le.jsxs)(M.T,{size:13,colour:G.colours.amber,children:["Running ",(0,z.minsBetween)(new Date(`${e.date}T${e.time}:00`),ae)," min late. Call them, then mark no-show if needed."]}):null,xe.ok?(0,le.jsx)(c.BookingEditButton,{rid:ne,booking:e,who:de,role:re,inStaffApp:ce,shiftManager:he,big:!0,testID:`edit-booking-${e.id}`}):null,(0,le.jsxs)(M.Row,{wrap:!0,gap:6,children:[(0,le.jsx)(u.BookingTableButton,{rid:ne,booking:e,readOnly:De||!xe.ok,turnBase:ie.settings.turnMins,canClear:me.ok}),xe.ok?null:(0,le.jsx)(W.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,le.jsx)(M.T,{children:j.BOOKING_VIEW_ONLY})}),xe.ok?(0,le.jsxs)(le.Fragment,{children:[De||e.table||!['seated','confirmed'].includes(e.status)?null:(0,le.jsx)(M.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>ke.assignTable(e)}),!De&&['seated','confirmed'].includes(e.status)?(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,V.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>ke.combineTables(e)}):null,De||'confirmed'!==e.status?null:(0,le.jsxs)(le.Fragment,{children:[me.ok&&e.date===oe?(0,le.jsx)(M.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(ne,e)}):null,(0,le.jsx)(M.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>_.repo.bookings.setStatus(e.id,'noshow')})]}),De||e.walkIn?null:(0,le.jsx)(r.CancelBookingButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),De||e.walkIn?null:(0,le.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:oe}),De||'seated'!==e.status?null:(0,le.jsx)(K.FinishButton,{rid:ne,b:e,name:(0,U.walkInLabel)(e),allowed:me.ok,hint:me.hint,small:!0,a11y:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,testID:`bookings-finish-${e.id}`}),['confirmed','pending'].includes(e.status)&&e.date>=oe?(0,le.jsx)(ee.WhatsAppGuest,{b:e,rid:ne,kind:"auto"}):null,ce?null:(0,le.jsx)($.CopyReviewLink,{rid:ne,bookingId:e.id}),!De&&e.walkIn?(0,le.jsx)(d.CancelWalkInButton,{rid:ne,b:e,small:!0}):null,!De&&e.walkIn?(0,le.jsx)(d.ReinstateWalkInButton,{rid:ne,b:e,today:oe,small:!0}):null,(0,le.jsx)(Y.BookingUndo,{b:e,rid:ne,today:oe,who:(0,U.walkInLabel)(e),allowed:me.ok})]}):null]}),'noshow'===e.status&&'paid'===t?(0,le.jsx)(M.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,le.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(ue,be,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:be===oe?'today':'that day'}),(0,le.jsxs)(M.Card,{children:[(0,le.jsxs)(M.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsx)(M.T,{weight:"semibold",children:"No-shows"}),(0,le.jsx)(M.Badge,{kind:Te.length?'red':'ok',label:`${Te.length} ${be===oe?'today':(0,z.niceDate)((0,z.parseYmd)(be)).slice(0,6)}${Ce||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,le.jsx)(M.Muted,{children:Te.length?`Marked no-show today: ${Te.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${Te.length>6?` and ${Te.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,le.jsx)(t.GreensideCashOnly,{}):(0,le.jsxs)(M.Card,{children:[(0,le.jsx)(M.T,{weight:"semibold",children:"Deposits"}),(0,le.jsx)(M.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,B.depositOf)(ie.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,le.jsx)(M.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),Fe,ke.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),w=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=_r(_d[31]),W=(e=O)&&e.__esModule?e:{default:e},M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),F=_r(_d[40]),U=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53])},1407,[805,1408,1093,1261,1409,812,822,1113,1114,1089,1118,1410,1119,1115,1395,1396,1055,1331,994,1116,1087,841,1122,1412,1231,1413,1387,1076,1053,1088,17,85,777,1353,858,845,851,863,1313,804,1178,1096,1111,996,1348,1060,1156,1414,1222,946,1180,1392,862,8]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return null}},1408,[]); __d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1409,[806,17,85,777,946,1265,8]); @@ -1500,7 +1500,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1417,[17,278,85,777,857,804,1418,8]); __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1418,[]); __d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{background-image:radial-gradient(1.2px 1.2px at 23px 41px,#fff,transparent),radial-gradient(1px 1px at 97px 13px,#fff9,transparent),radial-gradient(1.4px 1.4px at 151px 120px,#f5e6c8,transparent),radial-gradient(1px 1px at 61px 163px,#fffa,transparent),radial-gradient(1.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1419,[888,813,17,1067,319,219,385,278,24,85,856,885,876,816,946,966,878,776,804,884,777,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ae,me:ne,today:ie}=(0,A.useCtx)(5e3),re=(0,p.useOrders)(n),de=(0,p.useBookings)(n),ce=(0,p.useWaitlist)(n),he=(0,p.useEvents)(n),ye=(0,p.useRatings)(n),xe=(0,j.useOwner)(e=>e.staff),me=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),be=(0,j.useOwner)(e=>e.shifts),fe=(0,M.useRealHistory)(n,F),pe=(0,l.useMemo)(()=>(0,s.forecastToday)(x,de,re,he,F,fe??void 0),[x,de,re,he,fe,F.getTime()/6e4|0]),je=(0,S.useExamples)(),ke=(0,N.useCashUp)(e=>e.cashUps),we=de.filter(e=>e.date===ie),$e=re.filter(B.LIVE),ve=ce.filter(e=>'waiting'===e.status||'notified'===e.status),Ie=(0,C.seatedCoversOn)(de,ie),Ce=(0,oe.coversSplit)(we,ie),De=$e.filter(e=>(0,_.chainNeedsAction)(e,de)),Te=we.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,$e)),Be=$e.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Ae=pe.nextHour,Le=(0,B.busyLevel)(Ae?.coversHigh??0,pe.busy.busy),Me=(0,B.restOfDayLevel)(pe,x),Se=re.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===ie).reduce((e,t)=>e+t.paid,0),Ne=(0,R.tradingDay)(F),Pe=je?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Fe=je?{today:186e3+Se,last:Pe?{date:(0,I.ymd)(Pe.date),pence:Pe.total}:null,online:0,show:!0}:(0,O.takingsToday)(ke,n,Ne,Se),We=j.CAN.takings(ae)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),He=(0,l.useMemo)(()=>(0,L.insights)(x,de,re,he,ye,F,Ie),[x.id,de.length,ye.length,Ie]),Re=((0,A.weekday)(F),(0,k.openWorkingRows)(me,ie)),Oe=(0,ee.useFrontDoor)(ie),ze=(0,u.useBookingWrite)(),Ee=(0,w.useOutstanding)(),Ge=(0,i.useTravelDay)('owner',ie),Ue=(0,A.useSignedIn)(),qe=(0,A.useInStaffApp)(),Ye=(0,P.canSeeMonthTakings)(ae,Ue,{inStaffApp:qe,live:(0,H.isLive)()}),Ke=(0,W.homeSetupNagsHidden)(n),Ve=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Qe,Xe]=(0,l.useState)(!1),[Ze,Je]=(0,l.useState)(!1),et=ne.replace(' (example)',''),tt=j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ge?(0,le.jsxs)(b.default,{style:{gap:12},children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(i.DayView,{rid:n,day:Ge,today:ie,app:"owner"})]}):(0,le.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[tt,(0,le.jsx)(i.DayBar,{app:"owner",today:ie}),(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(V.AssistantPendingCard,{}),Ue&&'owner'!==Ue.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,Ue?(0,le.jsx)(X.MyTasksToday,{rid:n,staffId:Ue.id,name:Ue.name,onShift:(0,J.shiftNow)(Ue.id,Date.now()).on}):null,'staff'!==ae?(0,le.jsx)(Z.TodaysTipsCard,{rid:n,today:ie}):null,'staff'!==ae?(0,le.jsx)(Z.TipsPotCard,{rid:n,today:ie}):null,j.CAN.manage(ae)?(0,le.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,le.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,le.jsx)(ge,{split:Ce}),(0,le.jsx)(te.BlocksBanner,{rid:n,now:F,by:ne}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ie,by:ne,app:"owner",canConfirm:j.CAN.manage(ae)}),j.CAN.manage(ae)&&!Ke?(0,le.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ae)&&!Ke?(0,le.jsx)(o.SeasonsTodo,{go:e}):null,(0,le.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Xe(!0),style:{minHeight:56}}),(0,le.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(c.QuietButton,{label:"New booking",onPress:Oe.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),j.CAN.manage(ae)?(0,le.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ne}):null]}),Oe.elements,j.CAN.manage(ae)?(0,le.jsx)(Y.PaydaysCard,{go:e}):null,(0,le.jsx)(E.FadeIn,{children:(0,le.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Ae?` \xb7 ${(0,A.fmtH)(Ae.hour)}\u2013${(0,A.fmtH)(Ae.hour+1)}`:'']}),pe.example?(0,le.jsx)(M.ExampleBadge,{}):pe.enough?(0,le.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(E.Gauge,{pct:Ae?Le.pct:0,label:Ae?Le.label:pe.open?'Kitchen closing':'Closed today',sub:Ae&&!pe.enough?`${Ae.booked} booked${Ae.walkIns?` + ${Ae.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Ae?`Estimated ${(0,s.coversRange)(Ae.coversLow,Ae.coversHigh)} \xb7 Busy at ${pe.busy.busy} Covers an hour \xb7 ${Ae.booked} booked + about ${Ae.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Ae.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[pe.enough?(0,le.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Me.level.label}${Me.peak?`, peak ${(0,A.fmtH)(Me.peak.hour)}`:''}`}):null,pe.enough?(0,le.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(pe.restOfDay.low,pe.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${pe.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${pe.restOfDay.booked} Covers`})]}),pe.flags.length?(0,le.jsxs)(f.Muted,{center:!0,children:["Calendar: ",pe.flags.join(', ')]}):null,j.CAN.forecasts(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||$e.length?(0,le.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Live orders",value:"",accent:$e.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${$e.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${$e.filter(e=>'table'===e.type).length} table`:`${$e.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(E.CountUp,{value:$e.length})})}):null,ve.length>0?(0,le.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${ve.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,le.jsx)(E.CountUp,{value:ve.length})})}):null,We&&Fe.show?(0,le.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(z.TakingsTodayCard,{t:Fe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:De.length+Te.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(E.CountUp,{value:De.length+Te.length,colour:De.length+Te.length?T.colours.red:T.colours.ok})})})]}),De.length+Te.length+Be.length?(0,le.jsx)(B.SectionHead,{title:"Needs action now"}):null,De.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ne,compact:!0})]},e.id)),Te.map(e=>(0,le.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ne})]},e.id)),Be.map(t=>(0,le.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(f.T,{size:14,children:t.detail}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ae)&&(Ee.days.length||Ee.requests)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ee.days.length?`${Ee.days.length} earlier day${Ee.days.length>1?'s':''} to sign off`:''}${Ee.days.length&&Ee.requests?' \xb7 ':''}${Ee.requests?`${Ee.requests} correction request${Ee.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&j.CAN.publishSocial(ae)?(0,le.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(B.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(f.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(B.SectionHead,{title:e})}),(0,le.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(f.Badge,{kind:"ok",label:`${Re.length} clocked in`})}),(0,le.jsxs)(f.Card,{children:[0===Re.length?(0,le.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Re.map(e=>{const t=xe.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(be,e.staffId,ie),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,le.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(b.default,{style:{flex:1},children:[(0,le.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,le.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,le.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ae)?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ae?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(B.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((t,s)=>(0,le.jsx)(E.FadeIn,{delay:100+90*s,children:(0,le.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,le.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,le.jsx)(f.Muted,{children:t.body}),t.action?(0,le.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,le.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ye?(0,le.jsx)(f.Button,{testID:"home-takings-button",kind:Ze?'secondary':'primary',label:Ze?'Hide takings':'Takings',accessibilityLabel:Ze?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>Je(e=>!e),style:{minHeight:56}}):null,Ye&&Ze?(0,le.jsx)(E.FadeIn,{children:(0,le.jsx)(ue,{rid:n,today:ie})}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Qe,onClose:()=>Xe(!1),rid:n,by:et,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ce,_e.MonthTakingsCard=ue,_e.WalkInSplitCard=ge;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]);const ae=18,ne=18,ie=150,re=34;function de(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sae+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function ue({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yae+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ce(k,r):[],z=(e,t,s,l,a)=>(0,le.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,le.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,le.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,le.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,le.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,le.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,le.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,le.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,le.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ie,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:ae,y1:$,x2:r-ne,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:`${de(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,le.jsx)(a.Path,{d:de(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,le.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,le.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,le.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,le.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ie,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,le.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:re,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,le.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,le.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,le.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const he='#3A2F1E';function ge({split:e}){return(0,le.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:he,borderWidth:1,borderColor:T.colours.gold},children:[(0,le.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,le.jsx)(b.default,{style:{flex:1,backgroundColor:he}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,8]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:x,now:F,role:ne,me:ie,today:re}=(0,A.useCtx)(5e3),de=(0,p.useOrders)(n),ce=(0,p.useBookings)(n),ue=(0,p.useWaitlist)(n),ge=(0,p.useEvents)(n),xe=(0,p.useRatings)(n),me=(0,j.useOwner)(e=>e.staff),be=(0,j.useOwner)(e=>(0,j.liveAttendance)(e.attendance)),fe=(0,j.useOwner)(e=>e.shifts),pe=(0,M.useRealHistory)(n,F),je=(0,l.useMemo)(()=>(0,s.forecastToday)(x,ce,de,ge,F,pe??void 0),[x,ce,de,ge,pe,F.getTime()/6e4|0]),ke=(0,S.useExamples)(),we=(0,N.useCashUp)(e=>e.cashUps),$e=ce.filter(e=>e.date===re),ve=de.filter(B.LIVE),Ie=ue.filter(e=>'waiting'===e.status||'notified'===e.status),Ce=(0,C.seatedCoversOn)(ce,re),De=(0,oe.coversSplit)($e,re),Te=ve.filter(e=>(0,_.chainNeedsAction)(e,ce)),Be=$e.filter(e=>['confirmed','seated'].includes(e.status)&&(0,_.bookingNeedsAction)(e,ve)),Ae=ve.flatMap(e=>(0,v.readinessFor)(e,x,F).map(t=>({...t,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Le=je.nextHour,Me=(0,B.busyLevel)(Le?.coversHigh??0,je.busy.busy),Se=(0,B.restOfDayLevel)(je,x),Ne=de.filter(e=>e.paid>0&&!!e.createdAt&&(0,I.ymd)(new Date(e.createdAt))===re).reduce((e,t)=>e+t.paid,0),Pe=(0,R.tradingDay)(F),Fe=ke?(0,L.revenueHistory)(x,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,We=ke?{today:186e3+Ne,last:Fe?{date:(0,I.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,O.takingsToday)(we,n,Pe,Ne),He=j.CAN.takings(ne)&&(!(0,H.isLive)()||(0,H.can)('takings.view')),Re=(0,l.useMemo)(()=>(0,L.insights)(x,ce,de,ge,xe,F,Ce),[x.id,ce.length,xe.length,Ce]),Oe=((0,A.weekday)(F),(0,k.openWorkingRows)(be,re)),ze=(0,ee.useFrontDoor)(re),Ee=(0,u.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,i.useTravelDay)('owner',re),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,P.canSeeMonthTakings)(ne,qe,{inStaffApp:Ye,live:(0,H.isLive)()}),Ve=(0,W.homeSetupNagsHidden)(n),Qe=(0,j.useOwner)(e=>e.socialPosts.reduce((e,t)=>e+('awaiting approval'===t.status?1:0),0)),[Xe,Ze]=(0,l.useState)(!1),[Je,et]=(0,l.useState)(!1),tt=ie.replace(' (example)',''),st=j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,ae.jsxs)(b.default,{style:{gap:12},children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(i.DayView,{rid:n,day:Ue,today:re,app:"owner"})]}):(0,ae.jsxs)(b.default,{style:{gap:12},testID:a?'owner-home':'managers-home',children:[st,(0,ae.jsx)(i.DayBar,{app:"owner",today:re}),(0,ae.jsx)(K.WhoBar,{}),(0,ae.jsx)(V.AssistantPendingCard,{}),qe&&'owner'!==qe.role?(0,ae.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,ae.jsx)(X.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,J.shiftNow)(qe.id,Date.now()).on}):null,'staff'!==ne?(0,ae.jsx)(Z.TodaysTipsCard,{rid:n,today:re}):null,'staff'!==ne?(0,ae.jsx)(Z.TipsPotCard,{rid:n,today:re}):null,j.CAN.manage(ne)?(0,ae.jsx)(b.default,{testID:"home-business-insights-wrap",style:{alignItems:'center',width:'100%'},children:(0,ae.jsx)(f.Button,{testID:"home-business-insights",label:"Business insights",accessibilityLabel:"Business insights, stats and percentages from your bookings and cash ups",onPress:()=>e('more','bizinsights'),style:{minHeight:56,width:'100%'}})}):null,(0,ae.jsx)(le.SuperProInsights,{go:e}),(0,ae.jsx)(ye,{split:De}),(0,ae.jsx)(te.BlocksBanner,{rid:n,now:F,by:ie}),(0,ae.jsx)(y.KitchenSignoffs,{rid:n,today:re,by:ie,app:"owner",canConfirm:j.CAN.manage(ne)}),j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(q.SetupCard,{go:e}):null,j.CAN.manage(ne)&&!Ve?(0,ae.jsx)(o.SeasonsTodo,{go:e}):null,(0,ae.jsx)(r.LastFoodBanner,{rid:n,now:F}),(0,ae.jsx)(d.NextTableFreeCard,{rid:n,now:F}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:Ee.hint,disabled:!Ee.ok,onPress:()=>e('more','blocks')}):null,(0,ae.jsx)(f.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,ae.jsxs)(b.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,ae.jsx)(c.QuietButton,{label:"New booking",onPress:ze.openBooking,testID:"home-booking",disabled:!Ee.ok,accessibilityHint:Ee.hint}),j.CAN.manage(ne)?(0,ae.jsx)(te.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:x,now:F,by:ie}):null]}),ze.elements,j.CAN.manage(ne)?(0,ae.jsx)(Y.PaydaysCard,{go:e}):null,(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsxs)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center'},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Le?` \xb7 ${(0,A.fmtH)(Le.hour)}\u2013${(0,A.fmtH)(Le.hour+1)}`:'']}),je.example?(0,ae.jsx)(M.ExampleBadge,{}):je.enough?(0,ae.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,ae.jsx)(E.Gauge,{pct:Le?Me.pct:0,label:Le?Me.label:je.open?'Kitchen closing':'Closed today',sub:Le&&!je.enough?`${Le.booked} booked${Le.walkIns?` + ${Le.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Le?`Estimated ${(0,s.coversRange)(Le.coversLow,Le.coversHigh)} \xb7 Busy at ${je.busy.busy} Covers an hour \xb7 ${Le.booked} booked + about ${Le.walkIns} walk-ins${(0,h.showTakeaway)(x)?` \xb7 about ${Le.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[je.enough?(0,ae.jsx)(f.Badge,{kind:"gold",label:`Rest of today: ${Se.level.label}${Se.peak?`, peak ${(0,A.fmtH)(Se.peak.hour)}`:''}`}):null,je.enough?(0,ae.jsx)(f.Badge,{kind:"neutral",label:`${(0,s.coversRange)(je.restOfDay.low,je.restOfDay.high)}${(0,h.showTakeaway)(x)?` \xb7 about ${je.restOfDay.takeaway} takeaways`:''}`}):(0,ae.jsx)(f.Badge,{kind:"neutral",label:`Booked so far: ${je.restOfDay.booked} Covers`})]}),je.flags.length?(0,ae.jsxs)(f.Muted,{center:!0,children:["Calendar: ",je.flags.join(', ')]}):null,j.CAN.forecasts(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,ae.jsxs)(f.Row,{wrap:!0,gap:10,children:[(0,h.showTakeaway)(x)||ve.length?(0,ae.jsx)(E.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Live orders",value:"",accent:ve.some(e=>'new'===e.status)?T.colours.red:void 0,onPress:()=>e('orders'),sub:(0,D.orderAtTableOn)(x)?`${ve.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${ve.filter(e=>'table'===e.type).length} table`:`${ve.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,ae.jsx)(E.CountUp,{value:ve.length})})}):null,Ie.length>0?(0,ae.jsx)(E.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${Ie.reduce((e,t)=>e+t.partySize,0)} Covers waiting`,children:(0,ae.jsx)(E.CountUp,{value:Ie.length})})}):null,He&&We.show?(0,ae.jsx)(E.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(z.TakingsTodayCard,{t:We,example:ke,onPress:()=>e('more','analytics')})}):null,(0,ae.jsx)(E.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,ae.jsx)(B.Tile,{label:"Allergy alerts",value:"",accent:Te.length+Be.length?T.colours.red:T.colours.ok,sub:"Need a sign-off",children:(0,ae.jsx)(E.CountUp,{value:Te.length+Be.length,colour:Te.length+Be.length?T.colours.red:T.colours.ok})})})]}),Te.length+Be.length+Ae.length?(0,ae.jsx)(B.SectionHead,{title:"Needs action now"}):null,Te.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.AllergyChain,{o:e,me:ie,compact:!0})]},e.id)),Be.map(e=>(0,ae.jsxs)(B.AlertBox,{colour:T.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,ae.jsx)(f.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,ae.jsx)(U.BookingAllergyChain,{b:e,me:ie})]},e.id)),Ae.map(t=>(0,ae.jsxs)(B.AlertBox,{colour:'overdue'===t.state?T.colours.red:T.colours.amber,title:`${'cook'===t.stage?'START COOKING':'bag'===t.stage?'BAG IT':'READY'} \xb7 ${t.order.ref} pickup ${(0,I.hm)(new Date(t.order.slotTime))}${'overdue'===t.state?' \xb7 OVERDUE':''}`,children:[(0,ae.jsx)(f.T,{size:14,children:t.detail}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},t.id)),j.CAN.manage(ne)&&(Ge.days.length||Ge.requests)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,ae.jsx)(f.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Qe&&j.CAN.publishSocial(ne)?(0,ae.jsxs)(B.AlertBox,{colour:T.colours.amber,title:`SOCIAL \xb7 ${Qe} post${Qe>1?'s':''} awaiting approval`,children:[(0,ae.jsx)(f.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,ae.jsx)(B.SectionHead,{title:"Quick actions"}),(0,ae.jsxs)(m.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:T.colours.gold,backgroundColor:e?T.colours.goldTint:T.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,ae.jsxs)(f.Row,{gap:4,children:[(0,ae.jsx)(G.Mark,{p:"facebook"}),(0,ae.jsx)(G.Mark,{p:"instagram"}),(0,ae.jsx)(G.Mark,{p:"tiktok"}),(0,ae.jsx)(G.Mark,{p:"youtube"})]}),(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"bold",children:"Post to social"}),(0,ae.jsx)(f.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,ae.jsx)(f.T,{colour:T.colours.gold,size:20,children:"\u203a"})]}),(0,ae.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,ae.jsx)(B.SectionHead,{title:e})}),(0,ae.jsx)(B.SectionHead,{title:"Who\u2019s on now",right:(0,ae.jsx)(f.Badge,{kind:"ok",label:`${Oe.length} clocked in`})}),(0,ae.jsxs)(f.Card,{children:[0===Oe.length?(0,ae.jsx)(f.Muted,{children:"Nobody clocked in yet."}):null,Oe.map(e=>{const t=me.find(t=>t.id===e.staffId),s=(0,j.shiftOf)(fe,e.staffId,re),o=new Date(e.in),l=!!s&&o.getHours()+o.getMinutes()/60-s.start>.08333333333333333;return(0,ae.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,ae.jsxs)(b.default,{style:{flex:1},children:[(0,ae.jsx)(f.T,{weight:"semibold",children:t?.name??e.staffId}),(0,ae.jsxs)(f.Muted,{children:[t?.job," \xb7 in ",(0,I.hm)(o),s?` \xb7 shift ${(0,A.fmtH)(s.start)}\u2013${(0,A.fmtH)(s.end)}`:' \xb7 unscheduled']})]}),l?(0,ae.jsx)(f.Badge,{kind:"amber",label:"Late"}):(0,ae.jsx)(f.Badge,{kind:"ok",label:"On site"})]},e.id)}),j.CAN.manage(ne)?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==ne?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(B.SectionHead,{title:"Insights",sub:ke?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),Re.slice(0,4).map((t,s)=>(0,ae.jsx)(E.FadeIn,{delay:100+90*s,children:(0,ae.jsxs)(f.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:T.colours.gold,red:T.colours.red,amber:T.colours.amber,ok:T.colours.ok,blue:T.colours.blue}[t.tone]},children:[(0,ae.jsxs)(f.T,{weight:"semibold",children:[t.icon," ",t.title]}),(0,ae.jsx)(f.Muted,{children:t.body}),t.action?(0,ae.jsx)(f.Button,{small:!0,kind:"ghost",label:`${t.action.label} \u2192`,onPress:()=>e(t.action.tab,t.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},t.id)),(0,ae.jsx)(f.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,Ke?(0,ae.jsx)(f.Button,{testID:"home-takings-button",kind:Je?'secondary':'primary',label:Je?'Hide takings':'Takings',accessibilityLabel:Je?'Hide takings':'Takings: this month by day, from confirmed cash ups',onPress:()=>et(e=>!e),style:{minHeight:56}}):null,Ke&&Je?(0,ae.jsx)(E.FadeIn,{children:(0,ae.jsx)(he,{rid:n,today:re})}):null,(0,ae.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:tt,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=ue,_e.MonthTakingsCard=he,_e.WalkInSplitCard=ye;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=e(_r(_d[12])),m=e(_r(_d[13])),b=e(_r(_d[14])),f=_r(_d[15]),p=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),I=_r(_d[22]),C=_r(_d[23]),D=_r(_d[24]),T=_r(_d[25]),B=_r(_d[26]),A=_r(_d[27]),L=_r(_d[28]),M=_r(_d[29]),S=_r(_d[30]),N=_r(_d[31]),P=_r(_d[32]),F=_r(_d[33]),W=_r(_d[34]),H=_r(_d[35]),R=_r(_d[36]),O=_r(_d[37]),z=_r(_d[38]),E=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),_=_r(_d[42]),q=_r(_d[43]),Y=_r(_d[44]),K=_r(_d[45]),V=_r(_d[46]),Q=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),oe=_r(_d[54]),le=_r(_d[55]),ae=_r(_d[56]);const ne=18,ie=18,re=150,de=34;function ce(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const t=e.length,s=[],o=[];for(let o=0;o9){const n=3/Math.sqrt(a);o[e]=n*t*s[e],o[e+1]=n*l*s[e]}}let l=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let s=0;sne+(t-1)/Math.max(1,e-1)*s,l=[1,5,10,15,20,25].filter(t=>t=36)&&a.push(e);for(;a.length&&o(e)-o(a[a.length-1])<36;)a.pop();return[...a,e]}function he({rid:e,today:t}){const s=(0,N.useCashUp)(e=>e.cashUps),[o,i]=(0,l.useState)(t.slice(0,7)),[r,d]=(0,l.useState)(0),[c,u]=(0,l.useState)(null),h=(0,l.useMemo)(()=>(0,P.monthTakings)(s,e,o,t),[s,e,o,t]),y=(0,l.useMemo)(()=>(0,P.firstTakingsMonth)(s,e),[s,e]),p=!!y&&yne+(e-1)/Math.max(1,k-1)*w,C=e=>$-e/v*128,D=[];h.days.forEach((e,t)=>{if('recorded'!==e.state)return;const s={x:I(e.day),y:C(e.value)};t&&'recorded'===h.days[t-1].state?D[D.length-1].push(s):D.push([s])});const B=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),L=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===t):void 0)??A??B[B.length-1],M=e=>{const t=B.findIndex(e=>e.date===L?.date),s=B[Math.max(0,Math.min(B.length-1,t+e))];s&&(u(s.date),x.default.announceForAccessibility?.(S(s)))},S=e=>`${(0,P.longDay)(e.date)}, ${'recorded'===e.state?(0,P.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,W=h.current?`so far in ${h.month}`:`in ${h.month} ${o.slice(0,4)}`,H=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,P.monthName)((0,P.addMonths)(o,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,R=h.recorded?`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. ${(0,P.poundsWhole)(h.total)} ${W}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,P.longDay)(h.best.date)}, ${(0,P.poundsWhole)(h.best.value)}.${H?` ${H.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${o.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,O=r?ue(k,r):[],z=(e,t,s,l,a)=>(0,ae.jsx)(m.default,{testID:a,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!s},disabled:!s,onPress:()=>{i((0,P.addMonths)(o,l)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:s?e?.6:1:.25}),children:(0,ae.jsx)(f.T,{size:24,colour:T.colours.gold,center:!0,children:e})});return(0,ae.jsx)(f.Card,{highlight:T.colours.gold,style:{alignItems:'center',gap:6},children:(0,ae.jsxs)(b.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,ae.jsxs)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),p||j?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[z('\u2039',`Previous month, ${(0,P.monthName)((0,P.addMonths)(o,-1))}`,p,-1,'mt-prev'),(0,ae.jsxs)(f.T,{center:!0,colour:T.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",o.slice(0,4)]}),z('\u203a',`Next month, ${(0,P.monthName)((0,P.addMonths)(o,1))}`,j,1,'mt-next')]}):null,(0,ae.jsx)(b.default,{accessible:!0,accessibilityLabel:R,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(f.T,{size:38,weight:"bold",colour:T.colours.gold,center:!0,testID:"mt-total",children:(0,P.poundsWhole)(h.total)}),(0,ae.jsx)(f.T,{center:!0,colour:T.colours.goldLight,children:W}),(0,ae.jsxs)(f.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,P.shortDay)(h.best.date)," \xb7 ",(0,P.poundsWhole)(h.best.value)]}),H?(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-vs",children:H}):null]}):(0,ae.jsx)(f.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,ae.jsxs)(b.default,{style:{width:'100%',minWidth:0},children:[(0,ae.jsxs)(b.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:re,width:'100%',overflow:'visible'},children:[r?(0,ae.jsxs)(n.default,{width:r,height:re,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,ae.jsx)(a.Defs,{children:(0,ae.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,ae.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,ae.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,ae.jsx)(a.Line,{x1:ne,y1:$,x2:r-ie,y2:$,stroke:T.colours.hairline,strokeWidth:1}),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:`${ce(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${t}`)),D.filter(e=>e.length>1).map((e,t)=>(0,ae.jsx)(a.Path,{d:ce(e),stroke:T.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${t}`)),D.filter(e=>1===e.length).map((e,t)=>(0,ae.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:T.colours.gold},`s${t}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:$,r:2,fill:"none",stroke:T.colours.muted,strokeWidth:1},e.date)),L&&'recorded'===L.state?(0,ae.jsx)(a.Line,{x1:I(L.day),y1:10,x2:I(L.day),y2:$,stroke:T.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===t);return(0,ae.jsx)(a.Circle,{cx:I(e.day),cy:'recorded'===e.state?C(e.value):$,r:4.5,fill:T.colours.gold,stroke:T.colours.surface,strokeWidth:1.5})})():null,L&&'recorded'===L.state&&L.date!==t?(0,ae.jsx)(a.Circle,{cx:I(L.day),cy:C(L.value),r:5,fill:T.colours.surface,stroke:T.colours.gold,strokeWidth:2}):null]}):null,r?B.map(e=>(0,ae.jsx)(m.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:S(e),accessibilityState:{selected:L?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:re,left:I(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,ae.jsx)(b.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:O.map(e=>(0,ae.jsx)(f.T,{size:F.AXIS_FONT,colour:T.colours.muted,style:{position:'absolute',left:I(e)-17,width:de,top:0,textAlign:'center'},children:String(e)},e))})]}),L&&B.length?(0,ae.jsxs)(b.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,ae.jsx)(m.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:B[0]?.date===L.date,onPress:()=>M(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[0]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u2039"})}),(0,ae.jsxs)(b.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:S(L),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,ae.jsx)(f.Muted,{center:!0,children:L.date===t?`Today \xb7 ${(0,P.shortDay)(L.date)}`:(0,P.shortDay)(L.date)}),(0,ae.jsx)(f.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===L.state?T.colours.goldLight:T.colours.muted,children:'recorded'===L.state?(0,P.poundsWhole)(L.value):'pending'===L.state?'Not cashed up yet':'No cash-up'})]}),(0,ae.jsx)(m.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:B[B.length-1]?.date===L.date,onPress:()=>M(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B[B.length-1]?.date===L.date?.25:e?.6:1}),children:(0,ae.jsx)(f.T,{size:20,colour:T.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,ae.jsx)(f.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ge='#3A2F1E';function ye({split:e}){return(0,ae.jsx)(f.Card,{style:{alignItems:'center',gap:8},children:(0,ae.jsxs)(b.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,ae.jsx)(f.T,{weight:"semibold",colour:T.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,ae.jsx)(f.Muted,{center:!0,children:"No Covers yet"}):(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",colour:T.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,ae.jsxs)(b.default,{style:{alignItems:'center',minWidth:120},children:[(0,ae.jsx)(f.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,ae.jsx)(f.T,{size:14,colour:T.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,ae.jsxs)(b.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ge,borderWidth:1,borderColor:T.colours.gold},children:[(0,ae.jsx)(b.default,{style:{width:`${e.walkInPct}%`,backgroundColor:T.colours.gold}}),(0,ae.jsx)(b.default,{style:{flex:1,backgroundColor:ge}})]})]})]})})}},1420,[843,1137,1421,17,780,1179,1072,1073,1413,1331,861,1076,264,385,85,777,858,876,1204,1187,845,1154,863,1053,866,804,1178,1055,1136,1141,1142,1006,839,1146,886,946,961,1431,1432,1145,1433,1156,853,1436,1182,1202,1454,1201,1029,1030,1064,1096,1387,1149,1330,1455,8]); __d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:$}=(0,D.useCtx)(6e4),V=$.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsx)(j.Toggle,{label:`${e.name}: no deposit, paid on the night`,value:!!e.payOnNight,onChange:s=>pe(e.id,{payOnNight:s})}),e.payOnNight?null:(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Pre-order deposit each"}),(0,W.jsx)(K,{label:`${e.name} pre-order deposit`,min:0,max:200,value:Math.round((e.depositPence??0)/100),unit:e=>e?`\xa3${e}`:'None',onChange:s=>pe(e.id,{depositPence:100*s||void 0})})]}),(0,W.jsx)(j.Muted,{size:12,children:e.uses.length?`Uses: ${e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')} from the counted stock. Held from the Display count and shown as \u201cReserved\u201d.`:'Not taken from the counted stock.'})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),Re=J.hourOverrides??[],De=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:R.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),De?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:De}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!De,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),Re.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:Re.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:R.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...Re.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),$e=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,ze]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{ze(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:R.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From this many adults"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from this many adults"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:R.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more adults see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)(z.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:$e,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:R.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:R.colours.accentBorder,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:R.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:R.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,D.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:R.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:R.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:R.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),R=_r(_d[25]),D=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),$=_r(_d[31]),I=_r(_d[32]),z=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:R.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?R.colours.red:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:R.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:R.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:R.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:R.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:R.colours.hairline,backgroundColor:R.colours.surface2,color:R.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,$.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:R.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1421,[1051,1031,805,1408,812,1422,1423,1425,1426,1427,1197,1029,1030,1006,1012,17,385,85,777,841,1428,816,862,1053,861,804,1055,858,1181,972,973,876,1429,1382,996,1430,1003,1139,939,8]); __d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1422,[812,17,85,777,1137,861,804,8]); __d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1423,[843,17,219,85,777,858,996,1150,1254,946,1325,1424,8]); @@ -1535,170 +1535,173 @@ __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule' __d(function(_g,_r,i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1452,[17,264,385,85,777,804,961,1453,8]); __d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1453,[892,946,876,856,961]); __d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AssistantPendingCard=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),t=b(),[n,o]=(0,s.useState)(null),l=async()=>{try{o(await(0,r.assistantProposalsList)())}catch{o([])}};return(0,s.useEffect)(()=>{if(!e||!t)return;l();const s=setInterval(()=>{l()},2e4);return()=>clearInterval(s)},[e,t]),e&&t?(0,u.jsx)(y,{rows:n,onChanged:()=>{l()},compact:!0}):null},_e.AssistantsPage=function(){const e=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[t,l]=(0,s.useState)(''),[h,b]=(0,s.useState)(null),[x,f]=(0,s.useState)(!1),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),[v,D]=(0,s.useState)(null),I=async()=>{try{w(await(0,r.assistantList)())}catch{w([])}try{T(await(0,r.assistantProposalsList)())}catch{T([])}};(0,s.useEffect)(()=>{e&&I()},[e]);const C=t.replace(/\D/g,''),P=async()=>{f(!0),b(null);const e=await(0,r.assistantApprove)(C);f(!1),e.ok?(l(''),b({ok:!0,text:'Done. Tracy\u2019s assistant is paired. It can look things up and propose changes, which wait for Tracy to confirm on her phone.'}),I()):b({ok:!1,text:e.message})};return(0,u.jsxs)(n.default,{testID:"assistants-page",style:{gap:12},children:[e?(0,u.jsx)(y,{rows:k,onChanged:()=>{I()}}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Pair Tracy\u2019s assistant"}),(0,u.jsx)(o.T,{center:!0,children:"Ask Tracy\u2019s Grok Bot to start CoverCharge sign-in. It will show 6 numbers."}),(0,u.jsx)(o.T,{center:!0,children:"Only an owner can approve this. The bot can look things up and advise, and it can propose a change. Nothing is changed until Tracy confirms it on her phone. Important changes \u2014 permissions, opening hours, the table plan, cancelling or moving a booking, pay, menus, stock or price, online settings, or any delete \u2014 ask her a second time, with a plain warning of what is affected."}),(0,u.jsx)(o.Field,{testID:"assistant-code-field",label:"Code shown by the bot (6 numbers)",accessibilityLabel:"Code shown by the bot, 6 numbers",value:t,onChangeText:e=>l(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,u.jsx)(o.Button,{testID:"assistant-approve",label:x?'Approving\u2026':'Approve assistant',accessibilityHint:"Pairs Tracy\u2019s Grok Bot as an assistant for The Anchorage",disabled:!e||x||6!==C.length,onPress:()=>{P()},style:{minHeight:56}}),e?null:(0,u.jsx)(o.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve this."}),(0,u.jsx)(n.default,{accessibilityLiveRegion:"polite",accessible:!!h,accessibilityLabel:h?.text,children:h?(0,u.jsx)(o.T,{testID:"assistant-approve-msg",center:!0,weight:"semibold",colour:h.ok?c.colours.goldLight:c.colours.amber,children:h.text}):null}),(0,u.jsx)(o.Muted,{center:!0,children:"Never send Tracy\u2019s personal app link to the bot. That link stays on her phone. The bot cannot see sign-in links, PINs or the kitchen unlock code, and it cannot change its own access or pairing."})]}),(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:"Assistants paired"}),null===j?(0,u.jsx)(o.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):j.length?j.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,u.jsx)(o.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,u.jsx)(o.Button,{testID:`assistant-revoke-${e.id}`,kind:"secondary",label:"Unpair this assistant",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>D(e),style:{minHeight:56}})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No assistant is paired."})]}),v?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>D(null),title:"Unpair this assistant?",maxWidth:520,testID:"assistant-revoke-confirm",children:[(0,u.jsx)(o.T,{center:!0,children:`${v.label} stops working straight away. Any changes still waiting are cancelled. Tracy\u2019s phone is unchanged. To use the bot again, ask it for a new code and approve it here as an owner.`}),(0,u.jsx)(o.Button,{testID:"assistant-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=v;D(null);const s=await(0,r.assistantRevoke)(e.id);b(s.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:s.message}),I()},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",onPress:()=>D(null),style:{minHeight:56}})]}):null]})};var e,s=_r(d[0]),t=_r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},o=_r(d[2]),r=_r(d[3]),l=_r(d[4]),c=_r(d[5]),h=_r(d[6]),u=_r(d[7]);const p=e=>e?`${(0,l.niceDate)(new Date(e))} at ${(0,l.hm)(new Date(e))}`:'not yet';function b(){const e=(0,h.useSignedIn)(),s=(0,r.useSync)(e=>e.staffRef);return'st-tracy'===e?.id||'st-tracy'===s}function y({rows:e,onChanged:t,compact:l}){const h=b(),y=(e??[]).filter(e=>'pending'===e.status),[x,f]=(0,s.useState)(null),[j,w]=(0,s.useState)(null),[k,T]=(0,s.useState)(null),v=async(e,s,n=!1)=>{f(e.id),w(null);const o=await(0,r.assistantProposalDecide)(e.id,s,n);f(null),o.ok?(T(null),w('decline'===s?'Declined. Nothing was changed.':'Done. The change has been made, as Tracy\u2019s assistant (confirmed by Tracy).'),t?.()):w(o.message)};return!y.length&&l?null:(0,u.jsx)(n.default,{testID:l?'assistant-pending-home':'assistant-pending-list',children:(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{center:!0,size:18,weight:"semibold",colour:c.colours.goldLight,accessibilityRole:"header",children:h?'Waiting for you to confirm':'Waiting for Tracy to confirm'}),e?y.length?y.map(e=>(0,u.jsxs)(n.default,{testID:`assistant-pending-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:c.colours.border},children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:e.summary}),e.needsDoubleConfirm&&e.warning?(0,u.jsxs)(o.Muted,{center:!0,children:["This needs a second confirm. ",e.expiresAt?`Runs out at ${p(e.expiresAt)}.`:'']}):e.expiresAt?(0,u.jsx)(o.Muted,{center:!0,children:`Runs out at ${p(e.expiresAt)}.`}):null,h&&e.canDecide?(0,u.jsxs)(n.default,{style:{gap:8},children:[(0,u.jsx)(o.Button,{testID:`assistant-pending-approve-${e.id}`,label:x===e.id?'Working\u2026':'Approve',accessibilityHint:e.needsDoubleConfirm?'Opens a second confirm step because this change is important':'Applies this change, using your permissions',disabled:!!x,onPress:()=>{e.needsDoubleConfirm?T(e):v(e,'approve')},style:{minHeight:56}}),(0,u.jsx)(o.Button,{testID:`assistant-pending-decline-${e.id}`,kind:"secondary",label:"Decline",disabled:!!x,onPress:()=>{v(e,'decline')},style:{minHeight:56}})]}):(0,u.jsx)(o.Muted,{center:!0,children:"Only Tracy can confirm or decline this on her phone."})]},e.id)):(0,u.jsx)(o.Muted,{center:!0,children:"No changes are waiting."}):(0,u.jsx)(o.Muted,{center:!0,children:"Loading\u2026"}),j?(0,u.jsx)(o.T,{testID:"assistant-pending-msg",center:!0,weight:"semibold",colour:c.colours.goldLight,children:j}):null,k?(0,u.jsxs)(o.Sheet,{visible:!0,onClose:()=>T(null),title:"Please confirm this change",maxWidth:520,testID:"assistant-double-confirm",children:[(0,u.jsx)(o.T,{center:!0,weight:"semibold",children:k.warning||k.summary}),(0,u.jsx)(o.T,{center:!0,children:"This is an important change to how the venue works. Please read it carefully, then confirm again. Nothing is changed until you do."}),(0,u.jsx)(o.Button,{testID:"assistant-double-confirm-yes",label:x===k.id?'Working\u2026':'Yes, make this change',disabled:!!x,onPress:()=>{v(k,'approve',!0)},style:{minHeight:56}}),(0,u.jsx)(o.Button,{kind:"secondary",label:"Cancel",disabled:!!x,onPress:()=>T(null),style:{minHeight:56}})]}):null]})})}},1454,[17,85,777,946,863,804,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1455,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1456,804,856,1055,1457,1460,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1456,[1032]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1457,[812,17,362,385,278,85,777,1458,1459,804,1455,1055,876,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1458,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1459,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1460,[17,385,85,777,860,1459,996,842,1461,1456,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1461,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1462,[813,17,266,347,219,385,85,831,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1463,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1464,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1465,[831]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1466,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1467,8]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1467,[17,85,777,858,851,946,804,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return fe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),A=_r(d[19]),R=_r(d[20]),T=_r(d[21]),M=_r(d[22]),O=_r(d[23]),G=_r(d[24]),B=_r(d[25]),E=_r(d[26]),x=_r(d[27]),I=_r(d[28]),D=_r(d[29]),L=(e=D)&&e.__esModule?e:{default:e},N=_r(d[30]),_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),pe=_r(d[59]),ge=_r(d[60]),he=_r(d[61]),be=_r(d[62]);const fe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},ye=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:ye,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>ye(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:ye,C:G.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:ye,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>ye(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:ye,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:ye,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:ye,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:ye,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:ye,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:ye,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:ye,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:ye,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:ye,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:ye,C:A.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:ye,C:R.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:ye,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:ye,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:ye,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:ye,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:ye,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:ye,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:ye,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:I.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>fe(),C:I.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:ye,C:I.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:ye,C:I.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:I.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:ye,C:I.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:ye,C:I.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:ye,C:I.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:ye,C:I.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:I.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>L.default.createElement(_.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:N.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:N.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:_.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:H.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:Q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:ye,C:Q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:ye,C:Q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:ye,C:q.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:ye,C:q.DisplaySettingsPage}]);const Ce=e=>'owner'===e||'manager'===e;F.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Ce,C:F.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Ce,C:F.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:W.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:U.AssistantsPage}]);const Se=e=>'owner'===e||'manager'===e,ke=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},ve=e=>Se(e)&&ke();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:Se,C:V.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:ve,C:V.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:ve,C:V.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:ve,C:V.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:Se,C:V.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:Se,C:V.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:Se,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:V.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:ye,C:Y.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:ye,C:Y.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:ye,C:Y.Outbox}]);const we=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:we,C:K.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:K.optinsAllowed,C:K.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:we,C:z.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:we,C:j.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:we,C:$.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:we,C:J.OrderSheetSettings},...X.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:we,C:(0,j.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:we,C:Z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:we,C:ee.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:ye,C:ee.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:we,C:ee.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:we,C:te.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:ye,C:se.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:ye,C:se.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:ye,C:se.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:ye,C:ae.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:ye,C:ie.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:ye,C:oe.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:ye,C:ne.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ne.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ue.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,le.useCtx)(6e4),o=(0,le.useSignedIn)();return L.default.createElement(ce.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:Se,C:function(){const{rid:e,today:t}=(0,le.useCtx)(6e4);return L.default.createElement(ce.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:ye,C:re.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,le.useCtx)(6e4),s=(0,le.useSignedIn)();return L.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:ye,C:ge.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:ye,C:he.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:be.UseOnComputerPage}])},1468,[822,1048,856,1469,876,966,955,816,866,1471,1478,1486,1446,1487,1488,1490,1491,1155,1464,1492,1493,1495,1196,1187,1466,1496,1444,1497,1499,17,1193,1176,1445,1433,1447,1480,1504,1505,1454,1506,1436,1421,1507,1451,1508,886,1509,1510,1512,1182,1455,1513,1382,1457,1525,1079,1055,1197,1149,1528,1531,1534,1537]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1469,[17,378,219,385,85,19,777,1024,1327,876,804,1470,1184,1465,1055,8,260]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1470,[831]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1471,[812,1442,17,851,85,777,876,804,1055,884,885,1472,946,962,1029,1440,1473,1474,1476,994,1477,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1472,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1473,[812,17,85,777,804,876,1343,1342,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1474,[17,85,777,1475,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1475,[831,892,946,880]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1476,[17,85,777,804,960,1020,946,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1477,[892,946]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1478,[17,85,777,835,876,1479,804,1055,1480,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1479,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1480,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1481,1485,804,1055,1069,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1481,[1482,1484,1483]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1482,[843,1483]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1483,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1484,[1482,891]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1485,[869,824,831,834]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1486,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1487,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1488,[1037,17,85,1489,814,857,777,876,804,1055,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1489,[812,17,219,385,85,780,814,804,777,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1490,[17,1151,847,1055,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1491,[17,1030,1055,946,961,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1492,[17,1388,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1493,[17,85,780,777,858,1006,1494,804,1055,8]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1494,[839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1495,[17,85,1336,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1496,[17,776,1055,8]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1497,[17,85,777,858,1006,876,1053,1498,946,804,1232,1233,1055,8]); -__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1498,[839,1494]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1499,[805,1408,812,822,843,1500,1427,1470,1218,841,1254,946,1501,1503,1428,17,1096,1478,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1500,[843,17,85,777,845,851,1150,858,853,804,8]); -__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1501,[946,17,264,219,85,1272,777,1251,1254,804,1502,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1502,[17,219,85,777,1251,8]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1503,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1504,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1505,[17,85,777,946,863,804,8]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1506,[813,812,822,17,219,385,85,777,1220,858,1485,848,1222,1016,804,1025,1055,8]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1507,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1508,[17,385,85,777,876,998,851,999,804,840,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1509,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1510,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1511,804,880,1157,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1511,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1512,[17,85,777,804,1423,1500,1055,8]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1513,[812,1031,779,17,385,85,777,876,1462,1514,1515,1516,804,1055,8]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1514,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1515,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1516,[1517,1098,843,1518,1519,876,858,996,1462,1514,1515,1521,1520,1523,1524,994,995]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1517,[1062,1061,1021]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1518,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1519,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1520,1518]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1520,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1521,1522]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1521,[824,831,834]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1522,[824,831,834]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1523,[816,876,956,851,1520,1015,1069]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1524,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1525,[17,362,85,777,804,1458,1521,1470,1522,1352,890,1526,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1526,[17,85,777,804,1527,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1527,[824,831,834]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1528,[17,779,85,777,845,1251,1529,1530,804,8]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1529,[845]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1530,[946,1529,1254]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1531,[17,85,777,858,1006,1532,938,839,1533,1018,804,1055,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1532,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1533,[839,1007,1494]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1534,[812,17,85,777,1535,1019,804,1536,1055,8]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1535,[824,831,834]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1536,[1018,1019,935,892,946]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1537,[17,264,219,85,777,812,804,946,1418,1182,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1538,[219]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1540,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1541,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1462,1084,1082,1222,1235,938,876,1030,1470,880,946,804,1327,1542,1055,1480,1407,1155,1464,1466,1455,1446,1468,1538,1540,1548,1549,1550,1553,1556,8]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1542,[17,266,347,219,385,278,85,409,780,779,1327,1446,1468,1407,1155,1466,1464,1055,1024,777,858,876,863,946,880,804,1543,1544,1545,1546,1547,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1543,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1544,[17,780,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1545,[17,85,777,804,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1546,[17,385,1157,1158,816,805,777,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1547,[17,219]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1548,[1543]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1549,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1550,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1551,1540,1549,1552,8]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1551,[17,385,278,85,777,804,8]); -__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1552,[17,85,780,777,804,1551,1549,8]); -__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1553,[17,264,385,85,780,777,858,876,1554,961,1208,1453,804,1544,1055,1551,1555,1549,1552,1550,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1554,[831,834,824]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1555,[961]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1556,[17,85,777,804,1557,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1557,[]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1558,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1462,1085,1084,1082,1470,1222,880,804,1480,1407,1155,1055,1420,1464,1455,1466,1446,1468,1559,1538,1561,1563,1565,1562,8]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1559,[17,278,85,1489,857,777,876,814,1447,804,1560,1561,1562,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1560,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1561,[17]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1562,[17,85,777,804,8]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1563,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1560,1561,1562,1564,8]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1564,[876]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1565,[17,85,777,876,1058,804,1560,1561,1562,1049,1564,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1566,[13,17,856,1567,8]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1567,[1447,1568,813,958,1070,1500,1202,1203,1026,1023,1024,1501,1528,1503,1149,938,979,1569,976,880,1029,1030,1476,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1492,1487,1510,1570,1415,966,219,1237,1176,1182,1445,1196,1193,1463,1179,878,1205,1206,884,776,946,8]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1568,[17,85,777,1055,946,8]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1569,[219,977]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1570,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[13,17,856,8]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1572,[1440,946,778,1401,1573,993,13,1600,479,17,368,319,219,24,85,805,857,1063,856,1602,19,858,996,876,804,1415,966,987,1603,1604,1026,1605,1102,880,1006,960,1608,1372,8,1609,1610,1611,1612]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1573,[1574,1597,1599]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1574,[198,1575,1578,1592,1593,1594,1595,1596]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1575,[198,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1576,[1577]); -__d(function(g,r,i,a,m,e,d){},1577,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1578,[1579,198,1575,1592,1593]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1579,[1580,1581,1591]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1580,[1581,1585,1590]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1581,[198,355,1582,1586,1587,1588,1589,1585,1590]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1582,[198,1583,322,263,1584,1585]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1583,[487]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1584,[198,322]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1585,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1586,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1587,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1588,[1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1589,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1590,[355,1584]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1591,[17,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1592,[1579,198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1593,[1579,1592]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1594,[1575]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1595,[198,1575,1578,1576]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1596,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1597,[198,37,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1598,[198]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1599,[17,1574]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1600,[1601]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1601,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1602,[17,24,85,409,777,857,966,946,880,805,804,1543,1545,8]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1603,[951,868,867,946]); -__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1604,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); -__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1605,[805,779,812,17,368,266,347,363,219,385,278,409,85,1480,1351,880,780,1055,878,876,777,804,1516,891,1606,1514,1515,1470,1352,1527,890,1607,1524,8,260]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1606,[876,816,996]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1607,[831]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1608,[]); -__d(function(e,o,s,t,p,n,a){"use strict";p.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1609,[]); -__d(function(o,e,s,t,d,p,c){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1610,[]); -__d(function(o,e,s,t,d,p,f){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1611,[]); -__d(function(o,s,e,d,t,p,n){"use strict";t.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1612,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1613,[13,17,856,8]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1614,[1615]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1615,[8,1616,574]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1616,[17,155]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1617,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1618,[8,482,17,253,634]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHTS_PLAN_LABEL",{enumerable:!0,get:function(){return D}}),_e.useInsightsAccess=S,_e.SuperProInsights=B,_e.SuperProInsightsPage=function({go:e}){return S().any?(0,v.jsx)(n.default,{style:{alignItems:'center',width:'100%'},testID:"superpro-insights-page",children:(0,v.jsx)(B,{go:e})}):(0,v.jsx)(_,{})},_e.InsightsSalesPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.sales)return(0,v.jsx)(_,{});const i=r.sales;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-sales-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:6,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Last 7 days"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,children:null!=i.last7?(0,x.moneyGbp)(i.last7):'\u2014'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.prev7?`The 7 days before: ${(0,x.moneyGbp)(i.prev7)}${null!=i.changePct?` (${i.changePct>=0?'up':'down'} ${Math.abs(i.changePct)}%)`:''}`:'Nothing to compare with yet'}),(0,v.jsx)(l.Muted,{center:!0,children:null!=i.sph7?`Spend per head ${(0,x.moneyGbp)(i.sph7)}`:'Spend per head shows once days have a cash up and Covers'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Takings by week"}),(0,v.jsx)(R,{values:i.weeks.map(e=>e.gross),w:300,h:70}),i.weeks.slice().reverse().map(e=>(0,v.jsx)(E,{a:`${(0,b.ukDate)(e.from)} \u2013 ${(0,b.ukDate)(e.to)}`,b:null!=e.gross?`${(0,x.moneyGbp)(e.gross)} \xb7 ${e.days} day${1===e.days?'':'s'} cashed up`:'No signed-off cash ups'},e.to)),(0,v.jsx)(l.Muted,{center:!0,children:"Gross takings from signed-off cash ups only, as in Business insights. A day without a cash up is never counted as \xa30."})]}),(0,v.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Business insights",onPress:()=>e('more','bizinsights')}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Spend per head",onPress:()=>e('more','spendhead')})]})]})},_e.InsightsStockPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.stock)return(0,v.jsx)(_,{});const i=r.stock;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-stock-page",children:[(0,v.jsx)(O,{example:r.example}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Low or out now"}),(0,v.jsx)(l.Muted,{center:!0,children:"Live tracked stock (the counts on the Display, Staff and Head Chef apps), at or below each item\u2019s warn-at level."}),i.low.length?i.low.map(e=>(0,v.jsx)(E,{testID:`low-${e.key}`,tone:e.out?w.colours.red:w.colours.amber,a:`${e.name} \xb7 ${e.out?'none left':e.countText}`,b:`Warns at ${e.lowText}`},e.key)):(0,v.jsx)(l.Muted,{center:!0,children:i.tracked?'Nothing low.':'No tracked stock set up yet (Settings \u203a Stock items).'})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:`Price rises in the last ${b.RISE_DAYS} days`}),i.rises.length?i.rises.map(e=>(0,v.jsx)(E,{testID:`rise-${e.ingId}`,a:`${e.name} \xb7 up ${e.pct}%`,b:`${(0,y.gbp)(e.before)} \u2192 ${(0,y.gbp)(e.after)} a pack \xb7 ${(0,b.ukDate)(e.at)}${e.supplier?` \xb7 ${e.supplier}`:''}`},e.ingId)):(0,v.jsx)(l.Muted,{center:!0,children:"No price rises."}),(0,v.jsx)(l.Muted,{center:!0,children:i.lastCount?`Last full stock count ${(0,b.ukDate)(i.lastCount)}.`:'No full stock count yet.'})]}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Deliveries, stock & GP",onPress:()=>e('more','kitchencosts')})]})},_e.InsightsGpPage=function({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t);if(!o.gp)return(0,v.jsx)(_,{});const i=r.gp;return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-gp-page",children:[(0,v.jsx)(O,{example:r.example}),r.example?(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Menu GP, last 3 months"}),(0,v.jsx)(l.T,{size:30,weight:"bold",center:!0,colour:w.colours.gold,children:L(i.menu)}),null!=i.startMenu&&null!=i.menu?(0,v.jsx)(l.Muted,{center:!0,children:`${T(i.menu-i.startMenu)} points since ${(0,b.ukDate)(i.trend[0]?.week??'')}`}):null,(0,v.jsx)(R,{values:i.trend.map(e=>e.menu),w:300,h:80})]}):(0,v.jsx)(j.GpOverTime,{rid:s}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.amber,center:!0,children:"GP fell after a cost change (14 days)"}),i.drops.length?i.drops.map(e=>(0,v.jsx)(E,{testID:`drop-${e.dishId}`,tone:w.colours.amber,a:`${e.dish}: ${L(e.before)} \u2192 ${L(e.after)}`,b:`After the ${e.supplier||'delivery'} prices on ${(0,b.ukDate)(e.date)}`},e.dishId)):(0,v.jsx)(l.Muted,{center:!0,children:"No dish lost GP from a delivery in the last 14 days."})]}),(0,v.jsxs)(l.Card,{style:{alignItems:'center',gap:4,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:"Each dish over 3 months"}),i.dishes.length?i.dishes.map(e=>(0,v.jsx)(E,{a:`${e.name} \xb7 ${L(e.gp)}`,tone:e.gpe('more','kitchencosts')})]})},_e.InsightsClockPage=function({go:e}){const t=S(),o=P(),{list:r,source:i}=C(),[a,c]=(0,s.useState)('all');if(!t.clock)return(0,v.jsx)(_,{});const d='unsigned'===a?r.filter(e=>!1===e.signed):r,u=e=>{const s=new Date(e);return isNaN(s.getTime())?e:s.toLocaleString('en-GB',{day:'2-digit',month:'2-digit',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})};return(0,v.jsxs)(n.default,{style:{gap:12,alignItems:'center'},testID:"insights-clock-page",children:[(0,v.jsx)(O,{example:!!o}),(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(l.Button,{small:!0,kind:'all'===a?'primary':'secondary',label:`All (${r.length})`,onPress:()=>c('all'),testID:"clock-filter-all"}),(0,v.jsx)(l.Button,{small:!0,kind:'unsigned'===a?'primary':'secondary',label:`Not signed off (${r.filter(e=>!1===e.signed).length})`,onPress:()=>c('unsigned'),testID:"clock-filter-unsigned"})]}),(0,v.jsx)(l.Card,{style:{alignItems:'center',gap:2,width:'100%'},children:d.length?d.map(e=>(0,v.jsxs)(n.default,{testID:`clock-change-${e.id}`,accessible:!0,accessibilityLabel:`${b.KIND_WORDS[e.kind]} for ${e.staffName??e.staffRef}, shift ${(0,b.ukDate)(e.workDate)}. ${e.before?`Before ${e.before}. `:''}${e.after?`After ${e.after}. `:''}By ${e.by}, ${u(e.at)}.${!1===e.signed?' Not signed off yet.':''}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:!1===e.signed?w.colours.amber:w.colours.text,children:`${e.staffName??e.staffRef} \xb7 shift ${(0,b.ukDate)(e.workDate)}`}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,children:`${b.KIND_WORDS[e.kind]}${e.before||e.after?`: ${e.before??'\u2014'} \u2192 ${e.after??'\u2014'}`:''}`}),(0,v.jsx)(l.Muted,{center:!0,children:`By ${e.by} \xb7 ${u(e.at)}${e.reason?` \xb7 \u201c${e.reason}\u201d`:''}`}),!1===e.signed?(0,v.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}):e.signed?(0,v.jsx)(l.Badge,{kind:"gold",label:"Signed off since"}):null]},e.id)):(0,v.jsx)(l.Muted,{center:!0,children:`No clock-in changes in the last ${b.CLOCK_DAYS} days.`})}),(0,v.jsx)(l.Muted,{center:!0,children:'server'===i?'From the server\u2019s timesheet audit.':'synced'===i?'From the timesheet audit on your synced hours.':'Example figures.'}),(0,v.jsx)(l.Button,{small:!0,kind:"secondary",label:"Sign off hours",onPress:()=>e('more','signoff')})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),o=_r(_d[3]),r=e(o),l=_r(_d[4]),i=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),f=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),$=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),j=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]);const D='SuperPro';function S(){const{role:e}=(0,k.useCtx)(6e4),s=(0,k.useSignedIn)(),t=(0,k.useInStaffApp)();return(0,b.insightsAccess)({viewRole:e,signed:s,live:(0,$.isLive)(),inStaffApp:t,perm:e=>(0,$.can)(e)})}function P(){return(0,f.useExamples)()&&!(0,$.isLive)()?I.INSIGHTS_SAMPLE:null}function C(){const e=P(),t=(0,u.useOwner)(e=>e.attendance),n=(0,u.useOwner)(e=>e.staff),[o,r]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(e||!(0,$.isLive)())return;let s=!0;return(0,$.readClockChanges)(b.CLOCK_DAYS).then(e=>{s&&e&&r((0,b.clockChangesFromServer)(e))}),()=>{s=!1}},[e]),(0,s.useMemo)(()=>{if(e)return{list:e.clock,source:'example'};const s=e=>e.map(e=>({...e,staffName:e.staffName??n.find(s=>s.id===e.staffRef)?.name?.replace(' (example)','')??e.staffRef}));if(o)return{list:s(o),source:'server'};const r=(0,b.addDaysYmd)((new Date).toISOString().slice(0,10),-b.CLOCK_DAYS);return{list:s((0,b.clockChangesFromAttendance)(t,r)),source:'synced'}},[e,o,t,n])}function M(e){const t=P(),[n,o]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(t||!e||!(0,$.isLive)())return;let s=!0;return(0,$.readLoyaltyInsight)().then(e=>{s&&o(e?(0,b.loyaltyInsight)(e.raw,e.source):null)}),()=>{s=!1}},[t,e]),t?t.loyalty:e&&(0,$.isLive)()?n:null}function N(e,t){const n=P(),o=(0,c.useCashUp)(e=>e.cashUps),r=(0,c.useCashUp)(e=>e.sales),l=(0,i.useBookings)(e),f=(0,i.useOrders)(e),y=(0,a.useReviews)(e=>e.reviews),x=(0,u.useOwner)(e=>e.attendance),$=(0,k.useHourly)(),w=(0,d.useGpCalcView)(),j=(0,i.useRecipeCards)(e),I=(0,g.useShellStore)(s=>s.items[e]),v=(0,g.useShellStore)((0,p.useShallow)(s=>(0,g.venueCounts)(s,e)));return(0,s.useMemo)(()=>{if(n)return{example:!0,...n};const s=j.map(e=>({id:e.id,dish:e.dish,price:e.price})),i=new Date,a=(0,b.salesInsight)(o,l,e,t),c=x.filter(e=>!e.voided&&'confirmed'===(0,u.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,k.paidMins)(e,i).paid,hourly:$[e.staffId]??0}));return{example:!1,sales:a,stock:(0,b.stockInsight)((I??[]).filter(e=>!e.group),v,(s,t)=>(0,h.fmtStockCount)(e,s,t),w.ingredients,Object.values(w.counts??{}),t),gp:(0,b.gpInsight)(w.ingredients,w.cardCosts??{},s,w.settings,Object.values(w.deliveries??{}),t),bookings:(0,b.bookingsInsight)(l,e,t),orders:(0,b.ordersInsight)(f,e,t),reviews:(0,b.reviewsInsight)(y,e,t),labour:(0,b.labourInsight)(c,a.last7,t),salesReport:(0,b.salesReportInsight)(r,e)}},[n,o,r,l,f,y,x,$,e,t,w,j,I,v])}const L=e=>null==e?'\u2014':`${e.toFixed(1)}%`,T=e=>`${e>0?'+':''}${e.toFixed(1)}`;function R({values:e,w:s=220,h:t=44,testID:l}){const i=e.map((e,s)=>({v:e,i:s})).filter(e=>null!=e.v);if(i.length<2)return null;const a=Math.min(...i.map(e=>e.v)),c=Math.max(...i.map(e=>e.v))-a||1,d=t=>6+t/Math.max(1,e.length-1)*(s-12),u=e=>t-6-(e-a)/c*(t-12),g=i[i.length-1];return(0,v.jsx)(n.default,{testID:l,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{alignItems:'center'},children:(0,v.jsxs)(r.default,{width:s,height:t,children:[(0,v.jsx)(o.Polyline,{points:i.map(e=>`${d(e.i).toFixed(1)},${u(e.v).toFixed(1)}`).join(' '),stroke:w.colours.gold,strokeWidth:2.5,fill:"none"}),(0,v.jsx)(o.Circle,{cx:d(g.i),cy:u(g.v),r:3.5,fill:w.colours.gold})]})})}function G({title:e,big:s,line:n,tone:o,onPress:r,testID:i,children:a,a11y:c,plan:d}){return(0,v.jsxs)(t.default,{testID:i,accessibilityRole:"button",accessibilityLabel:c,accessibilityHint:"Opens the detail",onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:260,maxWidth:460,minHeight:168,borderRadius:16,borderWidth:1.5,borderColor:o??w.colours.gold,backgroundColor:e?w.colours.goldTint:w.colours.surface,padding:14,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,v.jsx)(l.T,{weight:"semibold",colour:w.colours.gold,center:!0,children:e}),d?(0,v.jsx)(l.T,{size:11,weight:"semibold",colour:w.colours.goldLight,center:!0,children:d.toUpperCase()}):null,(0,v.jsx)(l.T,{size:28,weight:"bold",center:!0,colour:o??w.colours.text,children:s}),(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.muted,children:n}),a,(0,v.jsx)(l.T,{size:w.font.small,center:!0,colour:w.colours.goldLight,children:"Open \u203a"})]})}function O({example:e}){return(0,v.jsxs)(n.default,{style:{alignItems:'center',gap:4},testID:"superpro-insights-head",children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.T,{size:20,weight:"bold",colour:w.colours.gold,center:!0,accessibilityRole:"header",children:"Insights"}),e?(0,v.jsx)(l.Badge,{kind:"neutral",label:"Example figures"}):null]}),(0,v.jsx)(l.Muted,{center:!0,children:"Every figure CoverCharge holds, in one place, from your own records. Owners only."})]})}function A({title:e,sub:s,children:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,style:{gap:8,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(l.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,v.jsx)(l.Badge,{kind:"gold",label:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]}),(0,v.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',width:'100%'},children:t})]})}function B({go:e}){const{rid:s,today:t}=(0,k.useCtx)(6e4),o=S(),r=N(s,t),l=C(),i=M(o.loyalty);if(!o.any)return null;const a=(0,b.clockSummary)(l.list),c=(0,b.loyaltyLine)(i),d=s=>e('more',s),u=r.sales,g=r.stock,h=r.gp,p=r.bookings,f=r.orders,$=r.reviews,j=r.labour,I=r.salesReport,P=e=>b.INSIGHT_PLAN[e],B=e=>null==e?'\u2014':(0,x.moneyGbp)(Math.round(e)).replace(/\.00$/,''),_=o.sales||o.stock||o.gp||o.clock,E=o.bookings||o.noshows||o.orders||o.loyalty||o.reviews||o.labour||o.salesReports;return(0,v.jsxs)(n.default,{testID:"superpro-insights",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,v.jsx)(O,{example:r.example}),_?(0,v.jsxs)(A,{testID:"insights-group-superpro",title:D,sub:"Connected EPOS insights",children:[o.sales?(0,v.jsx)(G,{plan:P('sales'),testID:"insight-card-sales",title:"Sales & takings",onPress:()=>d('insights-sales'),big:B(u.last7),line:null==u.last7?'No signed-off cash ups in the last 7 days':"Last 7 days"+(null!=u.changePct?` \xb7 ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)}% on the 7 before`:''),a11y:`Sales and takings. ${null!=u.last7?`Last 7 days ${(0,x.moneyGbp)(u.last7)}`:'No cash ups yet'}${null!=u.changePct?`, ${u.changePct>=0?'up':'down'} ${Math.abs(u.changePct)} percent`:''}`,children:(0,v.jsx)(R,{testID:"insight-sales-spark",values:u.weeks.map(e=>e.gross)})}):null,o.stock?(0,v.jsx)(G,{plan:P('stock'),testID:"insight-card-stock",title:"Stock",onPress:()=>d('insights-stock'),tone:g.low.length?w.colours.amber:void 0,big:g.low.length?`${g.low.length} low`:g.tracked?'None low':'\u2014',line:`${g.low.length?g.low.slice(0,2).map(e=>`${e.name} ${e.countText}`).join(', '):g.tracked?'Tracked stock above its warn-at levels':'No tracked stock yet'} \xb7 ${g.rises.length} price rise${1===g.rises.length?'':'s'} in ${b.RISE_DAYS} days`,a11y:`Stock. ${g.low.length} tracked items low or out. ${g.rises.length} price rises in ${b.RISE_DAYS} days`}):null,o.gp?(0,v.jsx)(G,{plan:P('gp'),testID:"insight-card-gp",title:"GP & price alerts",onPress:()=>d('insights-gp'),tone:h.drops.length?w.colours.amber:void 0,big:L(h.menu),line:null==h.menu?'Cost your recipe cards to see GP':`Menu GP${null!=h.startMenu?` \xb7 ${T(h.menu-h.startMenu)} pts in 3 months`:''} \xb7 ${h.drops.length} dish${1===h.drops.length?'':'es'} fell after a cost change`,a11y:`GP. Menu GP ${L(h.menu)}. ${h.drops.length} dishes fell after a cost change`,children:(0,v.jsx)(R,{testID:"insight-gp-spark",values:h.trend.map(e=>e.menu)})}):null,o.clock?(0,v.jsx)(G,{plan:P('clock'),testID:"insight-card-clock",title:"Clock-in changes",onPress:()=>d('insights-clock'),tone:a.unsigned?w.colours.amber:void 0,big:String(a.total),line:`Edits in ${b.CLOCK_DAYS} days \xb7 ${a.unsigned} not signed off yet${a.latest?` \xb7 latest by ${a.latest.by}`:''}`,a11y:`Clock-in changes. ${a.total} edits in ${b.CLOCK_DAYS} days, ${a.unsigned} not signed off`}):null]}):null,E?(0,v.jsxs)(A,{testID:"insights-group-pro",title:"Pro",sub:"Owner dashboard metrics",children:[o.salesReports?(0,v.jsx)(G,{plan:P('salesReports'),testID:"insight-card-salesreports",title:"Weekly sales report",onPress:()=>e('more','cashup'),big:B(I.gross),line:I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}${I.top.length?` \xb7 ${I.top.map(e=>e.name).join(', ')}`:''}`:'No signed-off weekly sales report yet',a11y:"Weekly sales report. "+(I.weekStart?`Week of ${(0,b.ukDate)(I.weekStart)}, ${B(I.gross)}`:'None yet')}):null,o.bookings?(0,v.jsx)(G,{plan:P('bookings'),testID:"insight-card-bookings",title:"Bookings & Covers",onPress:()=>e('more','bizinsights'),big:String(p.covers7),line:`Covers, last 7 days \xb7 ${p.coversPrev7} the 7 before${null!=p.walkInPct?` \xb7 ${p.walkInPct}% walk-ins`:''}`,a11y:`Bookings and Covers. ${p.covers7} Covers in the last 7 days, ${p.coversPrev7} the 7 before`}):null,o.noshows?(0,v.jsx)(G,{plan:P('noshows'),testID:"insight-card-noshows",title:"No-shows & deposits",onPress:()=>e('more','bizinsights'),tone:p.noShows30?w.colours.amber:void 0,big:null!=p.noShowPct?`${p.noShowPct}%`:'\u2014',line:`No-shows, 30 days (${p.noShows30}) \xb7 deposits asked ${p.deposits30.asked}, paid ${p.deposits30.paid}${o.sales?` (${(0,y.gbp)(p.deposits30.paidPence)})`:''}${p.deposits30.waived?`, let off ${p.deposits30.waived}`:''}`,a11y:`No-shows and deposits. No-show rate ${p.noShowPct??'not known'} percent over 30 days. ${p.deposits30.paid} of ${p.deposits30.asked} deposits paid`}):null,o.orders?(0,v.jsx)(G,{plan:P('orders'),testID:"insight-card-orders",title:"Orders & takeaway",onPress:()=>e('more','orders'),big:String(f.count7),line:`Orders, last 7 days \xb7 ${f.takeaway7} takeaway, ${f.table7} table \xb7 ${(0,y.gbp)(f.valuePence7)}`,a11y:`Orders and takeaway. ${f.count7} orders in 7 days, ${f.takeaway7} takeaway`}):null,o.reviews?(0,v.jsx)(G,{plan:P('reviews'),testID:"insight-card-reviews",title:"Reviews",onPress:()=>e('more','reviews'),tone:$.low30?w.colours.amber:void 0,big:null!=$.avg30?`${$.avg30.toFixed(1)} \u2605`:'\u2014',line:`${$.count30} review${1===$.count30?'':'s'} in 30 days \xb7 ${$.low30} at 1 or 2 stars`,a11y:`Reviews. Average ${$.avg30??'none'} stars from ${$.count30} reviews in 30 days`}):null,o.loyalty?(0,v.jsx)(G,{plan:P('loyalty'),testID:"insight-card-loyalty",title:"Loyalty",onPress:()=>e('more','loyalty'),big:c.big,line:c.line,a11y:`Loyalty. ${i?.members??'Not known'} members. ${i?.stampsMonth??'Not known'} stamps this month. ${i?.rewardsMonth??'Not known'} rewards redeemed this month`}):null,o.labour?(0,v.jsx)(G,{plan:P('labour'),testID:"insight-card-labour",title:"Wages & hours vs takings",onPress:()=>e('more','bizinsights'),tone:null!=j.pct7&&j.pct7>35?w.colours.amber:void 0,big:null!=j.pct7?`${j.pct7}%`:'\u2014',line:`Wages of takings, last 7 days \xb7 ${j.paidHours7} signed-off hours${null!=j.labour7?` \xb7 ${B(j.labour7)}`:''}`,a11y:`Wages and hours versus takings. ${j.pct7??'Not known'} percent over 7 days, ${j.paidHours7} hours`}):null]}):null]})}function _(){return(0,v.jsx)(l.Muted,{center:!0,children:"Insights are for owners."})}function E({a:e,b:s,tone:t,testID:o}){return(0,v.jsxs)(n.default,{testID:o,accessible:!0,accessibilityLabel:`${e}. ${s}`,style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:w.colours.border,width:'100%'},children:[(0,v.jsx)(l.T,{weight:"semibold",center:!0,colour:t,children:e}),(0,v.jsx)(l.Muted,{center:!0,children:s})]})}},1455,[17,385,85,780,777,858,1233,1006,951,876,942,944,864,1142,851,1456,1458,946,804,1055,1174,1459,8]); +__d(function(_g,_r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.rangeFor=u,_e.previousRange=function(n,e){const o=u(n,e);if('today'===e||'week'===e)return{from:(0,t.addDaysYmd)(o.from,-7*('week'===e?1:0)-('today'===e?1:0)),to:(0,t.addDaysYmd)(o.to,-7*('week'===e?1:0)-('today'===e?1:0))};const[r,s]=o.from.split('-').map(Number),l=`${1===s?r-1:r}-${String(1===s?12:s-1).padStart(2,'0')}-01`,c=(0,t.addDaysYmd)(`${12===s?r+1:r}-${String(12===s?1:s+1).padStart(2,'0')}-01`,-1),d=`${l.slice(0,7)}-${o.to.slice(8,10)}`;return{from:l,to:d<=c&&d>=l?d:c}},_e.changePct=function(t,n){return null==t||null==n||0===n?null:Math.round((t-n)/n*1e3)/10},_e.changeWords=function(t,n){if(null==t)return null;const e='today'===n?'yesterday':'week'===n?'last week':'last month';return 0===t?`No change vs ${e}`:`${t>0?'Up':'Down'} ${Math.abs(t)}% vs ${e}`},_e.canSeeTakingsStats=function(t,n,e){return!('owner'!==t&&'manager'!==t||n&&!e)},_e.coversInRange=function(t,n){let s=0,u=0;for(const l of t){if(!l.date||!e(l.date,n))continue;if(!r(l.status))continue;const t=l.partySize||0;o(l)?s+=t:u+=t}const l=s+u;if(!l)return{total:0,walkIns:0,bookings:0,walkInPct:null,bookingPct:null,empty:!0};const c=Math.round(s/l*100);return{total:l,walkIns:s,bookings:u,walkInPct:c,bookingPct:100-c,empty:!1}},_e.noShowRate=function(t,n,r){const s=t.filter(t=>(!r||t.restaurantId===r)&&e(t.date,n)&&!o(t));if(!s.length)return{rate:null,count:0,of:0,empty:!0};const u=s.filter(t=>'noshow'===t.status).length;return{rate:Math.round(u/s.length*1e3)/10,count:u,of:s.length,empty:!1}},_e.cancelRate=function(t,n,o){const r=t.filter(t=>(!o||t.restaurantId===o)&&e(t.date,n));if(!r.length)return{rate:null,count:0,of:0,empty:!0};const s=r.filter(t=>'cancelled'===t.status).length;return{rate:Math.round(s/r.length*1e3)/10,count:s,of:r.length,empty:!1}},_e.takingsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.grossOf)(l.vals);null!=n&&(s+=n,u+=1)}return u?{gross:Math.round(100*s)/100,days:u}:{gross:null,days:0}},_e.tipsInRange=function(n,o,r){let s=0,u=0;for(const l of n){if(l.rid!==o||!l.confirmedAt||!e(l.date,r))continue;const n=(0,t.combinedTips)(l.vals);null!=n&&(s+=n,u+=1)}return u?{tips:Math.round(100*s)/100,days:u}:{tips:null,days:0}},Object.defineProperty(_e,"tipsPctOfTakings",{enumerable:!0,get:function(){return l}}),_e.spendPerHeadInRange=function(t,o,r,s){const u=c(s.from,s.to),l=(0,n.dayRows)(t,o,r,s.to,u).filter(t=>e(t.date,s)&&null!=t.gross);if(!l.length)return{sph:null,covers:0,gross:null,days:0};const d=Math.round(100*l.reduce((t,n)=>t+n.gross,0))/100,f=l.reduce((t,n)=>t+n.covers,0);return{sph:f>0?Math.round(d/f*100)/100:null,covers:f,gross:d,days:l.length}},_e.labourCostInRange=function(t,n){let o=0,r=!1;for(const s of t)!e(s.date,n)||s.hourly<=0||s.paidMins<=0||(o+=s.paidMins/60*s.hourly,r=!0);return r?Math.round(100*o)/100:null},Object.defineProperty(_e,"labourPctOfTakings",{enumerable:!0,get:function(){return d}}),_e.repeatGuestPct=function(t,n,o){const r=new Set;for(const e of t){if(o&&e.restaurantId!==o)continue;if(!s(e.status)||e.date>=n.from)continue;const t=f(e);t&&r.add(t)}const u=new Set;let l=0,c=0;for(const d of t){if(o&&d.restaurantId!==o)continue;if(!s(d.status)||!e(d.date,n))continue;const t=f(d);t&&!u.has(t)&&(u.add(t),l+=1,r.has(t)&&(c+=1))}return l?{rate:Math.round(c/l*1e3)/10,count:c,of:l,empty:!1}:{rate:null,count:0,of:0,empty:!0}},_e.reviewAverage=function(t,n){const o=t.filter(t=>(null==t.status||'published'===t.status)&&e(t.createdAt.slice(0,10),n)&&Number.isFinite(t.rating));if(!o.length)return{avg:null,count:0,empty:!0};return{avg:Math.round(o.reduce((t,n)=>t+n.rating,0)/o.length*10)/10,count:o.length,empty:!1}},Object.defineProperty(_e,"UNAVAILABLE",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"moneyGbp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"pctLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"coversOn",{enumerable:!0,get:function(){return n.coversOn}});var t=_r(_d[0]),n=_r(_d[1]);const e=(t,n)=>t>=n.from&&t<=n.to,o=t=>!!t.walkIn||'walk-in'===t.source,r=t=>'cancelled'!==t&&'noshow'!==t,s=t=>'seated'===t||'finished'===t;function u(n,e){return'today'===e?{from:n,to:n}:'week'===e?{from:(0,t.weekStartOf)(n),to:n}:{from:`${n.slice(0,7)}-01`,to:n}}const l=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function c(n,e){let o=0,r=n;for(;r<=e&&o<400;)o+=1,r=(0,t.addDaysYmd)(r,1);return Math.max(1,o)}const d=(t,n)=>null==t||null==n||n<=0?null:Math.round(t/n*1e3)/10;function f(t){const n=(t.phone||'').replace(/\s+/g,'').toLowerCase(),e=(t.email||'').trim().toLowerCase();return n.length>=7?`p:${n}`:e.includes('@')?`e:${e}`:null}const g={weeklyGp:'Weekly GP and food cost need dish sales from a till link. CoverCharge does not have that yet, so no weekly GP is shown.',occupancy:'Table occupancy is not tracked. Busy levels are arrivals per hour, not how full the room was.',topDishes:'Top dishes and sales channels need a till link and are not shown.'},h=t=>null==t?null:`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=t=>null==t?null:`${Number.isInteger(t)?String(t):t.toFixed(1)}%`},1456,[839,1457]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1457,[839]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSIGHT_KEYS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"INSIGHT_PLAN",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isHeadChef",{enumerable:!0,get:function(){return a}}),_e.insightsAccess=function(e){if(e.inStaffApp||'owner'!==e.viewRole)return s;if(e.signed){if(a(e.signed))return s;if('owner'!==e.signed.role&&!0!==e.signed.ownerAccess)return s}else if(e.live)return s;const t=t=>!e.live||e.perm(t),n=t('takings.view'),o={sales:n,salesReports:n,gp:n,orders:n,labour:n&&t('wages.view'),stock:t('stock.manage'),clock:t('rota.manage')||t('attendance.view'),bookings:!0,noshows:!0,loyalty:!0,reviews:!0};return{...o,any:r.some(e=>o[e])}},Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return l}}),_e.addDaysYmd=c,Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return d}}),_e.salesInsight=function(e,t,r,o){const s={from:c(o,-6),to:o},a={from:c(o,-13),to:c(o,-7)},i=(0,n.takingsInRange)(e,r,s),l=(0,n.takingsInRange)(e,r,a),d=(0,n.spendPerHeadInRange)(e,t,r,s).sph,u=[];for(let t=7;t>=0;t--){const s=c(o,-7*t),a=c(s,-6),i=(0,n.takingsInRange)(e,r,{from:a,to:s});u.push({from:a,to:s,gross:i.gross,days:i.days})}const f=null!=i.gross&&null!=l.gross&&l.gross>0?Math.round((i.gross-l.gross)/l.gross*1e3)/10:null;return{last7:i.gross,prev7:l.gross,changePct:f,days7:i.days,sph7:d,weeks:u,empty:u.every(e=>null==e.gross)}},Object.defineProperty(_e,"RISE_DAYS",{enumerable:!0,get:function(){return u}}),_e.stockInsight=function(e,t,n,r,o,s){const a=e.filter(e=>e.active),i=a.map(e=>({i:e,n:t[e.key]??0})).filter(({i:e,n:t})=>t<=e.lowAt).map(({i:e,n:t})=>({key:e.key,name:e.plural||e.name,count:t,lowAt:e.lowAt,out:t<=0,countText:n(e,t),lowText:n(e,e.lowAt)})).sort((e,t)=>e.out===t.out?e.count/Math.max(1,e.lowAt)-t.count/Math.max(1,t.lowAt):e.out?-1:1),l=c(s,-30),d=[];for(const e of r){const t=[...e.prices??[]].filter(e=>e.at).sort((e,t)=>e.at.localeCompare(t.at));if(t.length<2)continue;const n=t[t.length-2],r=t[t.length-1];r.p>n.p&&n.p>0&&r.at.slice(0,10)>=l&&d.push({ingId:e.id,name:e.name,before:n.p,after:r.p,pct:Math.round((r.p-n.p)/n.p*1e3)/10,at:r.at.slice(0,10),supplier:e.supplier})}d.sort((e,t)=>t.pct-e.pct);const u=[...o].sort((e,t)=>t.date.localeCompare(e.date))[0];return{low:i,tracked:a.length,rises:d,lastCount:u?.date??null,empty:!a.length&&!d.length&&!u}},Object.defineProperty(_e,"GP_DROP_DAYS",{enumerable:!0,get:function(){return f}}),_e.gpInsight=function(n,r,o,s,a,i){const l=(0,e.menuGp)(n,r,o,s),d=(0,e.gpHistory)(a,l,'3m',i),u=d.points.find(e=>null!=e.menu)?.menu??null,f=l.dishes.map(e=>{const t=d.points.find(t=>null!=t.dishes[e.id])?.dishes[e.id];return{id:e.id,name:e.name,gp:e.gp,target:e.target,change:null!=t?Math.round(10*(e.gp-t))/10:null}}).sort((e,t)=>(e.change??0)-(t.change??0)),g=(0,t.marginDrops)(a,c(i,-14)).filter(e=>o.some(t=>t.id===e.dishId)).map(e=>({dishId:e.dishId,dish:e.dish,before:e.before,after:e.after,drop:Math.round(10*e.drop)/10,date:e.date,supplier:e.supplier}));return{menu:l.menu,startMenu:u,trend:d.points.map(e=>({week:e.week,menu:e.menu})),dishes:f,drops:g,underTarget:l.dishes.filter(e=>e.gp=t&&n.push({id:`${r.id}:reclock`,attendanceId:r.id,staffRef:r.staffId,workDate:r.date,kind:'reclock',after:r.in?m(r.in):void 0,by:'Themselves',at:r.in??`${r.date}T00:00:00Z`,signed:!!r.signOff})}return k(n)},_e.clockChangesFromServer=function(e){return k(e.filter(e=>p.has(e.action)||'deleted'===e.action||'reclock'===e.action).map(e=>({id:String(e.id),attendanceId:String(e.attendance_id),staffRef:String(e.staff_ref),staffName:e.staff_name??void 0,workDate:String(e.work_date).slice(0,10),kind:e.action,before:h(e.action,e.old_value),after:h(e.action,e.new_value),by:e.changed_by_name,at:String(e.changed_at),reason:e.reason??void 0,signed:'deleted'===e.action?null:e.signed??null})))},_e.clockSummary=function(e){return{total:e.length,unsigned:e.filter(e=>!1===e.signed).length,people:new Set(e.map(e=>e.staffRef)).size,editors:new Set(e.map(e=>e.by)).size,latest:e[0]??null}},Object.defineProperty(_e,"CLOCK_DAYS",{enumerable:!0,get:function(){return b}}),_e.bookingsInsight=function(e,t,r){const o=e.filter(e=>e.restaurantId===t),s={from:c(r,-6),to:r},a={from:c(r,-13),to:c(r,-7)},i={from:c(r,-29),to:r},l=(0,n.coversInRange)(o,s),d=(0,n.coversInRange)(o,a),u=(0,n.noShowRate)(o,i,t),f=(0,n.cancelRate)(o,i,t),g=o.filter(e=>{const t=e;return'deposit'===t.security&&!!t.date&&t.date>=i.from&&t.date<=i.to});return{covers7:l.total,coversPrev7:d.total,walkInPct:l.walkInPct,noShowPct:u.rate,noShows30:u.count,cancelPct:f.rate,deposits30:{asked:g.length,paid:g.filter(e=>(e.depositPaid??0)>0).length,paidPence:g.reduce((e,t)=>e+(t.depositPaid??0),0),waived:g.filter(e=>!!e.depositWaived).length}}},_e.ordersInsight=function(e,t,n){const r=c(n,-6),o=e.filter(e=>(!e.restaurantId||e.restaurantId===t)&&e.createdAt&&e.createdAt.slice(0,10)>=r&&e.createdAt.slice(0,10)<=n&&'cancelled'!==e.status);return{count7:o.length,takeaway7:o.filter(e=>'takeaway'===e.type).length,table7:o.filter(e=>'table'===e.type).length,valuePence7:o.reduce((e,t)=>e+(t.subtotal||0),0)}},_e.reviewsInsight=function(e,t,r){const o=e.filter(e=>!e.restaurantId||e.restaurantId===t),s={from:c(r,-29),to:r},a=(0,n.reviewAverage)(o,s);return{avg30:a.avg,count30:a.count,low30:o.filter(e=>e.createdAt.slice(0,10)>=s.from&&e.rating<=2).length}},_e.labourInsight=function(e,t,r){const o={from:c(r,-6),to:r},s=(0,n.labourCostInRange)(e,o),a=e.filter(e=>e.date>=o.from&&e.date<=o.to).reduce((e,t)=>e+t.paidMins,0);return{labour7:s,takings7:t,pct7:(0,n.labourPctOfTakings)(s,t),paidHours7:Math.round(a/6)/10}},_e.salesReportInsight=function(e,t){const n=e.filter(e=>e.rid===t&&e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0];if(!n)return{weekStart:null,gross:null,top:[]};const r='number'==typeof n.vals.gross?n.vals.gross:null;return{weekStart:n.weekStart,gross:r,top:[...n.categories].sort((e,t)=>t.amount-e.amount).slice(0,3)}},_e.loyaltyInsight=function(e,t){if(!e||'object'!=typeof e)return null;const n=w(e.members),r=w(e.stampsMonth),o=w(e.rewardsUsedMonth??e.rewardsMonth),s=w(e.stampsLastMonthToDate??e.stampsLastMonth);if(null==n&&null==r&&null==o)return null;const a=null!=r&&null!=s&&s>0?Math.round((r-s)/s*1e3)/10:null;return{members:n,stampsMonth:r,stampsLastMonth:s,stampsChangePct:a,rewardsMonth:o,source:t}},_e.loyaltyLine=function(e){const t=e=>null==e?'\u2014':String(e);if(!e)return{big:'\u2014',line:'Members \xb7 stamps this month \u2014 \xb7 rewards redeemed this month \u2014'};const n=null==e.stampsLastMonth?'':` (${t(e.stampsLastMonth)} by this date last month${null==e.stampsChangePct?'':`, ${e.stampsChangePct>0?'up':e.stampsChangePct<0?'down':'level'}${e.stampsChangePct?` ${Math.abs(e.stampsChangePct)}%`:''}`})`;return{big:t(e.members),line:`Members \xb7 stamps this month ${t(e.stampsMonth)}${n} \xb7 rewards redeemed this month ${t(e.rewardsMonth)}`}};var e=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]);const r=['sales','salesReports','gp','stock','clock','bookings','noshows','orders','loyalty','reviews','labour'],o={sales:'SuperPro',gp:'SuperPro',stock:'SuperPro',clock:'SuperPro',salesReports:'Pro',bookings:'Pro',noshows:'Pro',orders:'Pro',loyalty:'Pro',reviews:'Pro',labour:'Pro'},s=Object.fromEntries([...r.map(e=>[e,!1]),['any',!1]]),a=e=>/head chef/i.test(e.level??'')||/head chef/i.test(e.job??'');const i=e=>String(e).padStart(2,'0'),l=e=>`${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}`;function c(e,t){const[n,r,o]=e.split('-').map(Number),s=new Date(n,r-1,o);return s.setDate(s.getDate()+t),l(s)}const d=e=>/^\d{4}-\d{2}-\d{2}/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}`:e;const u=30;const f=14;const g={clock_in:'Clock-in changed',clock_out:'Clock-out changed',break:'Break changed',added:'Shift added by hand',voided:'Shift removed from hours',unvoided:'Shift put back in hours',deleted:'Shift deleted',reopened:'Signed-off shift reopened',reclock:'Clocked in again after clocking out',request_applied:'Correction request applied'},p=new Set(['clock_in','clock_out','break','added','voided','unvoided','reopened','request_applied']),m=e=>{const t=new Date(e);if(isNaN(t.getTime()))return e;try{return t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return`${i(t.getHours())}:${i(t.getMinutes())}`}};function h(e,t){if(null!=t&&''!==t)return'clock_in'!==e&&'clock_out'!==e||!/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(t)?'break'===e&&/^\d+$/.test(t)?`${t} min break`:t:m(t.replace(' ','T').replace(/([+-]\d{2})$/,'$1:00'))}const k=e=>e.sort((e,t)=>t.at.localeCompare(e.at));const b=30;const w=e=>'number'==typeof e&&Number.isFinite(e)&&e>=0?Math.round(e):null},1458,[954,952,1456]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INSIGHTS_SAMPLE",{enumerable:!0,get:function(){return t}});const t=null},1459,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=O,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=O(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',M[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:M[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withVenueQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function O(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const M={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':M[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsx)(u.T,{center:!0,size:13,colour:k.colours.muted,testID:"onboard-ota",style:{width:'100%'},children:"Free over-the-air updates. Over-the-air updates will be available free of charge to the app."}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from your suppliers? Add supplier links here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1460,[817,1184,17,264,266,347,378,219,278,85,19,777,857,860,876,996,1034,1035,805,842,1032,1461,804,856,1055,1462,1465,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,2:['09:00','16:00'],3:['09:00','16:00'],4:['09:00','16:00'],5:['09:00','20:00'],6:['09:00','20:00']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1461,[1032]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1462,[812,17,362,385,278,85,777,1463,1464,804,1460,1055,876,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1463,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1464,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1465,[17,385,85,777,860,1464,996,842,1466,1461,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1466,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1467,[813,17,266,347,219,385,85,831,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffHome=function({go:e}){const N=(0,y.useInStaffApp)(),{now:R,meId:z,me:H,r:P,today:F}=(0,y.useCtx)(3e4),_=(0,x.useSeatClearFinish)(),E=(0,s.useTravelDay)('staff',F),W=(0,h.useOwner)(e=>e.shifts),q=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),V=(0,h.useOwner)(e=>e.staffCanViewSuppliers),G=(0,h.useOwner)(e=>e.quickLinks),U=(0,h.useOwner)(e=>e.chat),Y=(0,h.useOwner)(e=>e.swaps),Q=(0,h.useOwner)(e=>e.leave),K=(0,O.workingShifts)(W,Q).filter(e=>e.staffId===z&&e.published&&e.date>=F).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),J=K.find(e=>e.date===F),X=q.filter(e=>e.staffId===z&&e.in&&!e.out&&R.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],Z=(0,j.usePay)(z,0),ee=(0,w.useOrders)(P.id),se=(0,w.useBookings)(P.id),te=ee.filter(e=>(0,C.LIVE)(e)&&e.allergies.length&&(0,S.nextStep)(e,(0,S.linkedBooking)(e,se))),ae=se.filter(e=>e.date===F&&['confirmed','seated'].includes(e.status)&&(0,S.bookingNeedsAction)(e,ee.filter(C.LIVE))),ie=se.filter(e=>(0,D.undoKind)(e,F)||e.walkIn&&'cancelled'===e.status&&e.date===F).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),le=U.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ne=Y.filter(e=>e.fromId===z&&'open'===e.status).length+Q.filter(e=>e.staffId===z&&'pending'===e.status).length,de=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...V?[['Suppliers',()=>e('more','suppliers')]]:[]];return!N&&E?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(s.DayView,{rid:P.id,day:E,today:F,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[N?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:F}),(0,L.jsx)(t.CoversToday,{rid:P.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(I.StaffAvatar,{id:z,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",H.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:N?P.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:N?`${R.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:P.id,today:F,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:X?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:X?`On shift since ${(0,c.hm)(new Date(X.in))}`:'Not clocked in'}),X?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,y.hmDur)(Math.max(0,Math.round((R.getTime()-new Date(X.in).getTime())/6e4)))}):null]}),J?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,y.fmtH)(J.start),"\u2013",(0,y.fmtH)(J.end),(0,m.cleanBadge)(J.badge)?` \xb7 ${(0,m.cleanBadge)(J.badge)}`:'']}):K[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",y.DAY3[K[0].day]," ",Number(K[0].date.slice(8))," ",(0,y.fmtH)(K[0].start),"\u2013",(0,y.fmtH)(K[0].end),(0,m.cleanBadge)(K[0].badge)?` \xb7 ${(0,m.cleanBadge)(K[0].badge)}`:'']}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:X?'secondary':'success',label:X?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),z?(0,L.jsx)(v.RequestTimeOff,{meId:z,me:H,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:P.id,by:H.replace(' (example)',''),app:"staff",readOnly:!_.ok}),ie.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",ie.length,")"]}),(0,L.jsx)(r.Muted,{children:_.ok?'Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo.':'Today\u2019s seated and finished parties. Ask a manager to change a booking or cancel a walk-in.'}),ie.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,B.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(A.FinishButton,{rid:P.id,b:e,name:s,allowed:_.ok,hint:_.hint,small:!0,testID:`staff-finish-${e.id}`}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:P.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:P.id,b:e,today:F,small:!0}):null,(0,L.jsx)(D.BookingUndo,{b:e,rid:P.id,today:F,who:s,allowed:_.ok})]})]},e.id)})]})}):null,te.length+ae.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsx)(r.T,{weight:"semibold",children:_.ok?`Allergy sign-offs (${te.length+ae.length})`:`Allergies today (${te.length+ae.length})`}),(0,L.jsx)(r.Muted,{children:_.ok?'Tap Sign off for your step. Your name and the time are recorded.':'Allergy notes for today. Ask a manager to sign off a step.'}),te.map(e=>(0,L.jsx)(k.AllergyChain,{o:e,me:H,readOnly:!_.ok},e.id)),ae.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,$.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,B.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(k.BookingAllergyChain,{b:e,me:H,readOnly:!_.ok}),_.ok?(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(T.WhatsAppGuest,{b:e,rid:P.id,kind:"auto"})}):null]},e.id))]}):null,le?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:le.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,y.hmDur)(Z.paid)," paid hours"]})]}),ne?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ne," request",ne>1?'s':''," waiting for a manager \u203a"]})}):null,(0,b.visibleLinks)(G,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(b.QuickLinksRow,{compact:!0})]}):null,N?null:(0,L.jsx)(o.default,{style:{gap:6},children:de.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),y=_r(d[14]),x=_r(d[15]),j=_r(d[16]),b=_r(d[17]),k=_r(d[18]),w=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),$=_r(d[26]),A=_r(d[27]),M=_r(d[28]),v=_r(d[29]),O=_r(d[30]),L=_r(d[31])},1468,[1179,1070,1113,1087,17,385,85,777,876,863,804,1088,1165,1162,1055,1116,1176,1433,1156,860,1180,853,1178,884,1348,996,843,1111,1193,1200,1069,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1469,[17,1053,85,409,777,858,1138,1137,861,863,804,876,1178,1055,1145,1141,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1470,[831]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,y]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),B=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=B.filter(e=>'due'===e.state||'overdue'===e.state),$=B.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,x.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,x.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,x.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),v.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&y(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),y=_r(d[13]),x=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),x=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,B]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,_]=(0,r.useState)(''),[F,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,y.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(x.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.guestPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(F),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(x.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:B,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:_,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:F,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"CoverCharge confirms by email"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),x.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:F.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),y=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,B.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,x.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,x.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,x.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:y,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1471,[805,1408,843,1382,17,85,777,858,860,866,845,851,1154,1103,863,804,1178,1055,1155,1156,853,1414,848,947,1472,8]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1472,[17,85,777,858,851,946,804,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return ye}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),h=_r(d[9]),b=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),P=_r(d[18]),R=_r(d[19]),A=_r(d[20]),T=_r(d[21]),G=_r(d[22]),M=_r(d[23]),O=_r(d[24]),I=_r(d[25]),B=_r(d[26]),E=_r(d[27]),x=_r(d[28]),D=_r(d[29]),L=_r(d[30]),N=(e=L)&&e.__esModule?e:{default:e},_=_r(d[31]),H=_r(d[32]),Q=_r(d[33]),q=_r(d[34]),F=_r(d[35]),V=_r(d[36]),W=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),z=_r(d[41]),K=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),se=_r(d[49]),ae=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),ue=_r(d[55]),le=_r(d[56]),ce=_r(d[57]),de=_r(d[58]),ge=_r(d[59]),pe=_r(d[60]),he=_r(d[61]),be=_r(d[62]),fe=_r(d[63]);const ye=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},Ce=e=>n.CAN.manage(e);(0,y.register)([{id:'chat',title:'Staff chat',sub:'Messages with the team on this venue',group:'Start here',can:Ce,C:w.Chat},{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>Ce(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:Ce,C:I.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:P.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:Ce,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>Ce(e)&&!r.IS_CAR,C:T.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:Ce,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:Ce,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:Ce,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:Ce,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:Ce,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:Ce,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:h.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:Ce,C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:b.PLAN_SUB,group:'Account',can:n.CAN.billing,C:b.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',C:B.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',C:M.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:M.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',can:Ce,C:O.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:M.Timesheets}]),(0,y.register)([{id:'bizinsights',title:'Business insights',sub:'Stats and percentages from your bookings, cash ups and rota',group:'Run the day',can:Ce,C:x.BusinessInsights},{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:E.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:E.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',can:Ce,C:R.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',can:Ce,C:A.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'End-of-night cash up, paid outs, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',can:Ce,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:E.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:E.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:E.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:Ce,C:E.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:Ce,C:E.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:Ce,C:E.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:Ce,C:E.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:Ce,C:E.ReviewEmailSettings},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:E.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:Ce,C:E.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:E.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:D.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>ye(),C:D.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:Ce,C:D.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:Ce,C:D.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:D.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:Ce,C:D.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:Ce,C:D.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:Ce,C:D.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:Ce,C:D.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:D.TabletPreview}]);const me=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',C:()=>N.default.createElement(H.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:_.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',can:me,C:_.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',can:me,C:H.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:Q.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',C:q.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:Ce,C:q.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:Ce,C:q.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:Ce,C:F.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:Ce,C:F.DisplaySettingsPage}]);const Se=e=>'owner'===e||'manager'===e;V.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:Se,C:V.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off and connected services',group:'Account',can:Se,C:V.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',can:e=>'owner'===e&&!r.IS_CAR,C:U.CarScreen}]),(0,y.register)([{id:'assistants',title:'Assistants',sub:'Pair Tracy\u2019s Grok Bot with a 6-digit code, or unpair it. Look-up only',group:'Account',can:e=>'owner'===e&&!r.IS_CAR,C:Y.AssistantsPage}]);const ke=e=>'owner'===e||'manager'===e,ve=e=>'owner'===e;(0,y.register)([{id:'superpro-insights',title:'Insights',sub:'Every owner metric in one place: sales, stock, GP, clock-in changes, bookings, orders, reviews, loyalty and wages',group:'Run the day',can:ve,C:G.SuperProInsightsPage},{id:'insights-sales',title:'Insights: Sales',sub:'SuperPro \xb7 takings by week, last 7 days against the 7 before, spend per head',group:'Run the day',can:ve,C:G.InsightsSalesPage},{id:'insights-stock',title:'Insights: Stock',sub:'SuperPro \xb7 low at the last count (par levels) and recent price rises',group:'Run the day',can:ve,C:G.InsightsStockPage},{id:'insights-gp',title:'Insights: GP',sub:'SuperPro \xb7 menu and dish GP over time, and dishes whose GP fell after a cost change',group:'Run the day',can:ve,C:G.InsightsGpPage},{id:'insights-clock',title:'Insights: Clock-in changes',sub:'SuperPro \xb7 who edited which shift, when, before and after, and edits not signed off',group:'Run the day',can:ve,C:G.InsightsClockPage}]);const we=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Pe=e=>ke(e)&&we();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ke,C:W.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Pe,C:W.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Pe,C:W.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Pe,C:W.SafetyPages.Prices},{id:'haccp',title:'CookSafe log',sub:'One food safety log on every device: temperatures, deliveries, reheating, cleaning, training, House Rules, allergen matrix, inspector export',group:'Compliance',can:ke,C:W.SafetyPages.Haccp},{id:'compliance',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'foodsafety',title:'CookSafe log',sub:'Opens the CookSafe log',group:'Retired',can:ke,C:W.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ke,C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',C:W.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:Ce,C:j.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:Ce,C:j.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:Ce,C:j.Outbox}]);const Re=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'bookingrules',title:'Online booking rules',sub:'Party sizes, large groups, areas, dogs, table requests, access, deposits and pre-orders, email, allergies',group:'Settings',can:Re,C:$.OnlineBookingRulesPage},{id:'optins',title:'Marketing opt-ins',sub:'Guests who ticked the marketing box (UK GDPR and PECR). Nothing is sent',group:'Grow',can:$.optinsAllowed,C:$.MarketingOptInsPage},{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Re,C:K.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Re,C:z.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Re,C:J.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Re,C:X.OrderSheetSettings},...Z.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Re,C:(0,z.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Re,C:ee.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Re,C:te.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:Ce,C:te.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Re,C:te.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Re,C:se.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:Ce,C:ae.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:Ce,C:ae.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:Ce,C:ae.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:Ce,C:ie.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:Ce,C:re.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:Ce,C:ne.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, supplier lists, offers, events and specials waiting for a yes; nothing is sent',group:'Run the day',can:Ce,C:ue.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift',group:'Run the day',C:ue.ShiftNotesPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(le.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',C:function(){const{rid:e,role:t,me:s,today:r}=(0,ce.useCtx)(6e4),o=(0,ce.useSignedIn)();return N.default.createElement(de.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ke,C:function(){const{rid:e,today:t}=(0,ce.useCtx)(6e4);return N.default.createElement(de.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',C:function(){const{rid:e,me:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(ge.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:Ce,C:oe.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',C:function(){const{me:e,role:t}=(0,ce.useCtx)(6e4),s=(0,ce.useSignedIn)();return N.default.createElement(pe.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:Ce,C:he.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:Ce,C:be.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,C:fe.UseOnComputerPage}])},1473,[822,1048,856,1474,876,966,955,816,866,1476,1483,1491,1446,1492,1493,1495,1496,1155,1469,1497,1498,1499,1455,1196,1187,1471,1500,1444,1501,1502,17,1193,1176,1445,1433,1447,1485,1507,1508,1454,1509,1436,1421,1510,1451,1511,886,1512,1513,1515,1182,1460,1516,1382,1462,1528,1079,1055,1197,1149,1531,1534,1537,1540]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return D}}),_e.DashCorners=C,_e.ServiceBoard=function(){const{role:e}=(0,x.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,j.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,j.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,j.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,j.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,j.jsx)(C,{onLeave:y}),(0,j.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,j.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,j.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,j.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,j.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,j.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?I((0,j.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]);const D=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function k({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,j.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,j.jsxs)(s.default,{children:[(0,j.jsx)(y.Icon,{name:t,colour:h.colours.gold}),u?(0,j.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function C({onLeave:e}){const t=(0,p.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>f.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,j.jsx)(k,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,j.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,j.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:D.filter(e=>'left'===e.side).map(n)}),(0,j.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[D.filter(e=>'right'===e.side).map(n),(0,j.jsx)(k,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')})]})]})}function I(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[16]);return t(e,document.body)}},1474,[17,378,219,385,85,19,777,1024,1327,876,804,1475,1184,1470,1055,8,260]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1475,[831]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1476,[812,1442,17,851,85,777,876,804,1055,884,885,1477,946,962,1029,1440,1478,1479,1481,994,1482,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1477,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1478,[812,17,85,777,804,876,1343,1342,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1479,[17,85,777,1480,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1480,[831,892,946,880]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, type the figures (including cash paid out of the till) and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1481,[17,85,777,804,960,1020,946,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1482,[892,946]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUPPORT_LINE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"PLAN_GUEST_APP_LINE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_GUEST_APP_DETAIL",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"PLAN_OTA_LINE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_OTA_TERM",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_DESKTOP_LINE",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_DESKTOP_DETAIL",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_DESKTOP_SUPERPRO_LINE",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"PLAN_PRICE_NOTE",{enumerable:!0,get:function(){return E}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"PLAN_SUPERPRO_NAME",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_SUPERPRO_PRICE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"PLAN_SUPERPRO_BLURB",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PLAN_SUPERPRO_EPOS_LINE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"PLAN_EARLY_TERM",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"PLAN_TERMS_LINE",{enumerable:!0,get:function(){return G}}),_e.PlanBilling=function(){const{now:e,role:n}=(0,c.useCtx)(6e4),y=(0,u.trialStatus)((0,s.defaultSimStart)(),e),[f,b]=(0,t.useState)(!1);return i.CAN.billing(n)?f?(0,h.jsx)($,{onBack:()=>b(!1)}):(0,h.jsxs)(o.default,{style:{gap:10},children:[(0,h.jsx)(l.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,h.jsxs)(l.Card,{highlight:d.colours.gold,children:[(0,h.jsxs)(o.default,{testID:"plan-founding",style:{alignItems:'center',gap:2},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:"EARLY ADOPTER OFFER \xb7 FIRST 50"}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:"Every Pro feature at the early-adopter price."}),(0,h.jsxs)(l.T,{size:30,style:{textAlign:'center'},weight:"bold",children:["\xa349",(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[E,". Usual Full Restaurant Pro App price \xa399 a month."]}),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-early-term",children:B})]}),(0,h.jsx)(o.default,{testID:"plan-early-list",style:{gap:4,marginTop:6,alignItems:'center'},children:F.map(([e,t])=>(0,h.jsxs)(o.default,{testID:e===j?'plan-early-guest-app':e===_?'plan-early-desktop':'Free customer support'===e?'plan-early-support':void 0,style:{alignItems:'center'},children:[(0,h.jsxs)(l.T,{size:13,weight:"semibold",style:{textAlign:'center'},children:["\u2713 ",e]}),(0,h.jsx)(l.Muted,{center:!0,size:12,children:t})]},e))})]}),(0,h.jsx)(l.Muted,{center:!0,children:"Usual prices"}),[['plan-usual-lite',L,R,M,D,'Usual price',''],['plan-usual-pro',v,C,N,z,'Usual price',''],['plan-superpro',S,k,I,Y,'1-year contract','No hardware included.']].map(([e,t,n,s,i,u,c])=>(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:e,style:{gap:2,alignItems:'center'},children:[(0,h.jsx)(l.T,{size:12,weight:"semibold",colour:d.colours.goldMuted,style:{textAlign:'center'},children:u.toUpperCase()}),(0,h.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:t}),(0,h.jsxs)(l.T,{size:26,weight:"bold",style:{textAlign:'center'},children:[n,(0,h.jsx)(l.T,{size:14,colour:d.colours.muted,children:" / month"})]}),(0,h.jsx)(l.Muted,{center:!0,children:E}),(0,h.jsx)(l.Muted,{center:!0,children:s}),'plan-superpro'===e?(0,h.jsx)(l.Muted,{center:!0,testID:"plan-superpro-epos-line",children:U}):null,i.map(e=>(0,h.jsxs)(l.T,{size:13,style:{textAlign:'center'},children:["\u2713 ",e]},e)),c?(0,h.jsx)(l.Muted,{center:!0,children:c}):null]})},e)),(0,h.jsx)(l.Muted,{center:!0,testID:"plan-terms",children:G}),(0,h.jsx)(l.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>b(!0),style:{alignSelf:'center'}}),(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,h.jsxs)(l.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,h.jsx)(l.T,{weight:"bold",colour:d.colours.gold,children:"free"}),"."]}),(0,h.jsx)(l.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,h.jsx)(l.Muted,{center:!0,children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, with free customer support for the length of your subscription. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(l.T,{children:"Free trial"}),(0,h.jsxs)(l.T,{weight:"bold",colour:d.colours.gold,children:[y.daysLeft," day",1===y.daysLeft?'':'s'," left"]})]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(100*(1-y.daysLeft/y.total))}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),(0,h.jsxs)(l.Muted,{center:!0,children:["Then \xa3",u.PLAN.monthlyPence/100," a month + VAT if applicable, per venue. Nothing starts automatically after your free month. The trial start date is not set up yet."]})]}),(0,h.jsx)(p.AssistantPlanCard,{}),(0,h.jsxs)(l.Card,{children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'center'},gap:8,children:[(0,h.jsx)(l.T,{weight:"semibold",children:"Free customer support"}),(0,h.jsx)(l.Badge,{kind:"gold",label:"Included"})]}),(0,h.jsxs)(l.Muted,{center:!0,children:[P,", on every plan. Setup is all done digitally. Support contact details: not set up yet."]})]})]}):(0,h.jsx)(l.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(_d[0]),n=r(_d[1]),o=(e=n)&&e.__esModule?e:{default:e},l=r(_d[2]),s=r(_d[3]),i=r(_d[4]),u=r(_d[5]),d=r(_d[6]),c=r(_d[7]),p=r(_d[8]),h=r(_d[9]);const y=!0,f='Early adopter offer, usual prices, free trial, set-up guide',b='. The owner dashboard and admin, and the owner desktop version (the complete ecosystem on Mac or PC), come with Full Restaurant Pro App (\xa399 a month), SuperPro (\xa3149 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',P='Free customer support for the length of your subscription',j='Downloadable customer app for guests\u2019 phones',A='Guests download your customer app on their own phones. Comes with every plan.',x='Free over-the-air updates',w='Over-the-air updates will be available free of charge to the app.',_='Owner desktop version: the complete ecosystem on Mac or PC',T='The same data, sign-ins and permissions, installable on a Mac or Windows PC.',O='Owner desktop version: the complete ecosystem on Mac or PC, with full ecosystem insights once your EPOS is connected',E='+ VAT if applicable, per venue',L='Customer & Takeaway App',v='Full Restaurant Pro App',S='SuperPro',R='\xa349',C='\xa399',k='\xa3149',M='The lite version: core features for smaller venues.',N='Every feature, every app.',I='Everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract.',U='Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in.',B='One-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice.',F=[['All Pro features','Every feature, every app.'],['12-month contract at \xa349',B],['One month free','Try everything before you pay anything.'],['Your brand','Your logo and colour in the \u201cYour venue\u201d app.'],[j,A],['Free customer support','For the length of your subscription.'],[_,T],[x,w]],D=['\u201cYour venue\u201d app, powered by CoverCharge','Collection ordering','Loyalty stamp card','Menu and allergens','Allergy checks on every basket','Private feedback',j,P,x],z=['Owner dashboard and admin','Supplier links',_,j,P,x],Y=['Everything in Full Restaurant Pro','A full venue app, staff and customer sides','The CoverCharge EPOS: tills, kitchen displays and waiter pads','Installed at your venue by us, EPOS checked',O,j,P,x],G='All prices + VAT if applicable, per venue. Early adopter offer: one-month free trial, then a 12-month contract at \xa349 a month, then rolling monthly at \xa399 with one month\u2019s notice. Customer & Takeaway App and Full Restaurant Pro App: one-month free trial, then rolling monthly. SuperPro: 12 months, then rolling monthly, no free trial. Free customer support for the length of your subscription, on every plan. The downloadable customer app for guests\u2019 phones comes with every plan. Over-the-air updates will be available free of charge to the app. The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App.',V=[['Choose what to switch on','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function $({onBack:e}){const[n,s]=(0,t.useState)([]);return(0,h.jsxs)(o.default,{style:{gap:10},testID:"setup-guide",children:[(0,h.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,h.jsx)(l.H2,{children:"Set-up guide"}),(0,h.jsxs)(l.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",n.length," of ",V.length," done."]}),(0,h.jsx)(o.default,{style:{height:8,backgroundColor:d.colours.border,borderRadius:4},children:(0,h.jsx)(o.default,{style:{height:8,width:`${Math.round(n.length/V.length*100)}%`,backgroundColor:d.colours.gold,borderRadius:4}})}),V.map(([e,t],i)=>{const u=n.includes(i);return(0,h.jsx)(l.Card,{children:(0,h.jsxs)(l.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,h.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:d.colours.gold,backgroundColor:u?d.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(l.T,{size:14,weight:"bold",colour:u?'#1a1610':d.colours.gold,children:u?'\u2713':String(i+1)})}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{weight:"semibold",children:e}),(0,h.jsx)(l.Muted,{children:t}),(0,h.jsx)(l.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>s(u?n.filter(e=>e!==i):[...n,i])})]})]})},e)}),(0,h.jsx)(l.Muted,{children:"Stuck? Free customer support is included for the length of your subscription. Ticks on this guide are not saved."})]})}},1483,[17,85,777,835,876,1484,804,1055,1485,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1484,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return I}}),_e.AssistantFab=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)(e=>e.enabled);return v(e)&&t?(0,C.jsxs)(r.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:j.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,C.jsx)(D,{size:22}),(0,C.jsx)(p.T,{weight:"bold",colour:T,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=I(e=>e.open),o=()=>I.getState().setOpen(!1),{rid:h,role:w,me:A}=(0,k.useCtx)(3e4),T=(0,y.useAssistant)(),B=M(),[P,E]=(0,a.useState)([]),[L,W]=(0,a.useState)(''),[z,$]=(0,a.useState)(!1),_=(0,a.useRef)(null);(0,a.useRef)(null);if((0,a.useEffect)(()=>{setTimeout(()=>_.current?.scrollToEnd?.({animated:!0}),50)},[P.length]),!e||!v(w))return null;const N=(e,t,s)=>y.useAssistant.getState().record({at:(new Date).toISOString(),by:A,role:w,asked:e,action:t,outcome:s}),F=(e,t="result")=>E(s=>[...s,{id:R(),from:'assistant',text:e,kind:t}]),H=async e=>{const t=e.trim();if(!t)return;let s;W(''),E(e=>[...e,{id:R(),from:'you',text:t}]);try{s=await(0,x.getProvider)('xai').interpret(t,B)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&N(t,'\u2014','not understood'),E(e=>[...e,{id:R(),from:'assistant',proposal:s,state:'open',asked:t}])},U=(e,t)=>E(s=>s.map(s=>s.id===e?{...s,state:t}:s)),G=async(e,t,n)=>{if(U(e.id,'confirmed'),'external'===t.kind)return N(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void F(S,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await f.repo.bookings.seatWalkIn(h,Number(o.party),s,'Added by Assistant'),s&&(0,b.resetTableLive)(h,s),F(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),N(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),F(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),N(e.asked,t.title,'done');break;case'price':await f.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),F(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),N(e.asked,t.title,'done');break;case'offer':m.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),F(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),N(e.asked,t.title,'done');break;case'rota':case'bookings':F(String(o.result)),N(e.asked,t.title,'looked up')}},V=e=>{U(e.id,'cancelled'),N(e.asked,e.proposal?.title??'\u2014','cancelled'),F('Cancelled. Nothing was changed.','note')},q='lite'===T.tier,K=(0,y.tasksUsed)(T);return(0,C.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,C.jsx)(u.default,{style:[p.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,C.jsxs)(u.default,{testID:"assistant-sheet",style:{backgroundColor:j.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:j.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.Row,{gap:8,style:{flex:1},children:[(0,C.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:18})}),(0,C.jsx)(p.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,C.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,C.jsx)(u.default,{testID:"assistant-demo-badge",children:(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),q?(0,C.jsxs)(u.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,C.jsx)(p.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,C.jsx)(p.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c.default,{ref:_,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===P.length?(0,C.jsxs)(u.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,C.jsxs)(p.T,{children:["Hi ",A.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,C.jsx)(p.Muted,{children:"Try:"}),x.SUGGESTED_PROMPTS.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:j.colours.surface2},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]}):null,P.map(e=>'you'===e.from?(0,C.jsx)(u.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,C.jsx)(p.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,C.jsx)(O,{m:e,onConfirm:(t,s)=>G(e,t,s),onCancel:()=>V(e)},e.id):'choose'===e.proposal.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),(0,C.jsx)(p.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>H(e.prompt)},e.label))})]},e.id):(0,C.jsxs)(u.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,C.jsx)(p.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,C.jsx)(r.default,{accessibilityRole:"button",onPress:()=>H(e),style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:8},children:(0,C.jsx)(p.T,{size:14,children:e})},e))]},e.id):(0,C.jsx)(u.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?j.colours.amberBg:j.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:j.colours.amber},children:(0,C.jsx)(p.T,{children:e.text})},e.id))]}),(0,C.jsxs)(p.Row,{gap:8,children:[(0,C.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:L,onChangeText:W,onSubmitEditing:()=>H(L),returnKeyType:"send",style:[p.styles.input,{flex:1,minWidth:0,width:40}]}),null,(0,C.jsx)(p.Button,{label:"Send",accessibilityLabel:"Send",disabled:!L.trim(),onPress:()=>H(L)})]}),(0,C.jsxs)(p.Muted,{center:!0,children:["Demo on this device \xb7 ",K," of ",y.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,k.useCtx)(6e4),s=(0,y.useAssistant)();return v(t)?(0,C.jsxs)(u.default,{style:{gap:12},children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{gap:10,children:[(0,C.jsx)(u.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,C.jsx)(D,{size:22})}),(0,C.jsxs)(u.default,{style:{flex:1},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,C.jsx)(p.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,C.jsx)(p.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>I.getState().setOpen(!0)}),(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,C.jsxs)(u.default,{testID:"assistant-log",style:{gap:6},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>y.useAssistant.getState().clearLog()}):null]}),(0,C.jsx)(p.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,C.jsx)(p.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,C.jsxs)(u.default,{style:{borderWidth:1,borderColor:j.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsxs)(p.T,{size:12,colour:j.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,C.jsx)(p.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,C.jsxs)(p.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,C.jsxs)(p.T,{size:13,colour:j.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,C.jsx)(p.Muted,{children:"The activity log is visible to the owner."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,k.useCtx)(6e4),t=(0,y.useAssistant)();return v(e)?(0,C.jsxs)(u.default,{style:{gap:12},testID:"assistant-settings",children:[(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,C.jsx)(p.Muted,{children:"Shows the gold Assistant button on every Managers screen."})]}),(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Connected services"}),B.map(e=>(0,C.jsxs)(u.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:j.colours.border,paddingTop:8},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{children:e.name}),(0,C.jsx)(p.Badge,{kind:"neutral",label:"Not connected"})]}),(0,C.jsxs)(p.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,C.jsx)(p.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,C.jsxs)(p.Card,{children:[(0,C.jsx)(p.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,C.jsx)(p.Muted,{children:"The Assistant comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,C.jsx)(p.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to CoverCharge\u2019s server to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,C.jsx)(p.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,y.useAssistant)(),t=(0,y.tasksUsed)(e),s=Math.min(1,t/y.FAIR_USE);return(0,C.jsxs)(p.Card,{children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,C.jsx)(p.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,C.jsx)(u.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${y.FAIR_USE} tasks used`,style:{height:8,backgroundColor:j.colours.border,borderRadius:4},children:(0,C.jsx)(u.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:j.colours.gold,borderRadius:4}})}),(0,C.jsxs)(p.Muted,{children:[t," of ",y.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]);_r(d[4]);var a=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var r=e(_r(d[8])),c=e(_r(d[9])),u=e(_r(d[10])),h=_r(d[11]),p=_r(d[12]),b=_r(d[13]),f=_r(d[14]),m=_r(d[15]),x=_r(d[16]),y=_r(d[17]),j=_r(d[18]),k=_r(d[19]),w=_r(d[20]),C=_r(d[21]);const A=!0,S='Nothing was sent or changed: this connection is not set up yet.',T='#1A1408',I=(0,h.create)(e=>({open:!1,setOpen:t=>e({open:t})})),v=e=>'owner'===e||'manager'===e,R=()=>Math.random().toString(36).slice(2,9);function D({size:e=24,colour:t=T}){return(0,C.jsx)(p.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function M(){const{rid:e,r:t,now:s,today:n}=(0,k.useCtx)(3e4),l=(0,f.useAllMenu)(e),r=(0,b.useTableNames)(e),c=(0,f.useBookings)(e),u=(0,m.useOwner)(e=>e.staff),h=(0,m.useOwner)(e=>e.shifts),p=(0,m.useOwner)(e=>e.offers),x=(0,m.useOwner)(e=>e.suppliers);return(0,a.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:l.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:r,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,w.workingShifts)(h,m.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,m.addDays)(n,-(0,m.weekdayOf)(n))&&e.date<=(0,m.addDays)(n,6-(0,m.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${x[0]?.contact??'Alex Sample'}, ${x[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),l,r,c,u,h,p,x])}function O({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[l,r]=(0,a.useState)(!1),[c,h]=(0,a.useState)('external'===o.kind?o.text:''),b='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,C.jsxs)(u.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:b?j.colours.gold:j.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:j.colours.surface2},children:[(0,C.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,C.jsx)(p.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,C.jsx)(p.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,C.jsx)(p.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,C.jsxs)(u.default,{style:{gap:6},children:[o.detail?(0,C.jsx)(p.Muted,{children:o.detail}):null,(0,C.jsx)(p.T,{size:14,colour:j.colours.muted,children:o.label}),l&&b?(0,C.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:h,style:[p.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,C.jsx)(u.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:j.colours.gold,paddingLeft:10},children:(0,C.jsxs)(p.T,{children:["\u201c",c,"\u201d"]})}),(0,C.jsxs)(p.Muted,{children:["Sends to: ",o.service.map(e=>x.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,C.jsxs)(u.default,{style:{gap:4},children:[(0,C.jsx)(p.Muted,{children:o.detail}),o.warning?(0,C.jsxs)(p.T,{size:13,colour:j.colours.amber,children:["\u26a0 ",o.warning]}):null]}),b?(0,C.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,C.jsx)(p.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,C.jsx)(p.Button,{small:!0,kind:"secondary",label:l?'Done editing':'Edit',testID:"edit-action",onPress:()=>r(!l)}):null,(0,C.jsx)(p.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,C.jsx)(p.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),b?(0,C.jsxs)(p.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}const B=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1485,[812,938,779,869,890,17,378,219,385,278,85,831,777,1096,858,876,1486,1490,804,1055,1069,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);Object.keys(o).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})})},1486,[1487,1489,1488]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1487,[843,1488]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1488,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Assistant (server, with on-device fallback)',interpret:s}},1489,[1487,891]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1490,[869,824,831,834]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{money:!0,label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1491,[805,1031,938,1408,813,812,822,1254,1428,17,385,393,85,864,777,858,876,845,851,863,804,1178,1055,1155,1433,1211,8]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1492,[843,17,85,1156,777,858,845,853,863,804,1178,1055,8]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1493,[1037,17,85,1494,814,857,777,876,804,1055,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1494,[812,17,219,385,85,780,814,804,777,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1495,[17,1151,847,1055,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1496,[17,1030,1055,946,961,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1497,[17,1388,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:t}=(0,c.useCtx)(6e4),n=(0,r.useBookings)(e),a=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,s.useState)('day'),w=(0,d.hasAnyTakings)(a,e),k=(0,d.dayRows)(a,n,e,t,14),f=(0,d.weekRows)(a,n,e,t,8),v=(0,d.averageSph)(k),$=(e,s,t,n,a)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${s}: ${'No takings entered'===n?'no takings entered':`spend per head ${n}`}, ${t}${a?`, ${a}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:s}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:t}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===n?h.colours.muted:h.colours.goldLight,size:'No takings entered'===n?13:16,children:n}),a?(0,u.jsx)(i.Muted,{center:!0,children:a}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:w?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:k.map(e=>({label:x(e.date),value:e.sph}))}),[...k].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var s=_r(_d[0]),t=e(s),l=e(_r(_d[1])),n=_r(_d[2]),a=e(n),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,s.useState)(320),[x,y]=(0,s.useState)(e.length);(0,s.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),w=Math.max(0,j-b),k=e.slice(w,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),S=e=>38+e*(f-76)/Math.max(1,k.length-1),T=e=>140-e/$*106,L=[];let D=[];k.forEach((e,s)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:s,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(a.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(n.Text,{x:60,y:T($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(a.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(n.Line,{x1:0,x2:f,y1:T($*e/4),y2:T($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,s)=>(0,u.jsx)(n.Polyline,{points:e.map(e=>`${S(e.i)},${T(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},s)),k.map((e,s)=>(0,u.jsx)(t.default.Fragment,{children:null==e.value?(0,u.jsx)(n.Circle,{cx:S(s),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(n.Circle,{cx:S(s),cy:T(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(n.Text,{x:S(s),y:T(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},w+s))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:k.map((e,s)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},w+s))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===w,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1498,[17,85,780,777,858,1006,1457,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1499,[17,85,1336,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1500,[17,776,1055,8]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BusinessInsights=function(){const{rid:e,now:s,role:$,today:w,signedIn:j}=(0,v.useCtx)(),[x,D]=(0,t.useState)('today'),P=(0,o.useBookings)(e),T=(0,l.useCashUp)(e=>e.cashUps),R=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),N=(0,v.useHourly)(),L=(0,b.useReviews)(e=>e.reviews),A=(0,h.canSeeTakingsStats)($,(0,p.isLive)(),(0,p.can)('takings.view'));(0,t.useEffect)(()=>{(0,y.ensureReviewSync)(e,'manage')},[e]);const C=(0,h.rangeFor)(w,x),M=(0,h.previousRange)(w,x),W=(0,t.useMemo)(()=>P.filter(t=>t.restaurantId===e),[P,e]),S=(0,h.coversInRange)(W,C),G=(0,h.coversInRange)(W,M),B=(0,h.noShowRate)(W,C,e),O=(0,h.noShowRate)(W,M,e),U=(0,h.cancelRate)(W,C,e),_=(0,h.cancelRate)(W,M,e),E='today'===x?(0,c.laterTodayCovers)(W,w):0,z=(0,h.takingsInRange)(T,e,C),F=(0,h.takingsInRange)(T,e,M),H=(0,h.spendPerHeadInRange)(T,W,e,C),V=(0,h.spendPerHeadInRange)(T,W,e,M),q=(0,h.tipsInRange)(T,e,C),J=(0,h.tipsInRange)(T,e,M),K=(0,t.useMemo)(()=>R.filter(e=>'confirmed'===(0,r.attStatus)(e)).map(e=>({date:e.date,paidMins:(0,v.paidMins)(e,s).paid,hourly:N[e.staffId]??0})),[R,N,s]),Q=(0,h.labourCostInRange)(K,C),X=(0,h.labourCostInRange)(K,M),Y=(0,h.labourPctOfTakings)(Q,z.gross),Z=(0,h.labourPctOfTakings)(X,F.gross),ee=(0,h.repeatGuestPct)(W,C,e),te=(0,h.repeatGuestPct)(W,M,e),se=(0,h.reviewAverage)(L.filter(t=>t.restaurantId===e),C),ne='today'===x?'today':'week'===x?'this week':'this month';return(0,f.jsxs)(n.default,{testID:"business-insights-screen",style:{gap:12,paddingBottom:24},children:[(0,f.jsx)(a.T,{weight:"semibold",size:u.font.title,center:!0,children:"Business insights"}),(0,f.jsx)(a.Muted,{center:!0,children:"Stats and percentages from your bookings, cash ups and confirmed hours. A gap means there is no figure yet, not zero."}),(0,f.jsx)(a.Row,{gap:8,style:{justifyContent:'center',flexWrap:'wrap'},children:k.map(e=>(0,f.jsx)(a.Chip,{testID:`insights-period-${e.id}`,label:e.label,selected:x===e.id,onPress:()=>D(e.id)},e.id))}),(0,f.jsx)(I,{testID:"insights-walkin-pct",label:`Walk-in vs booked \xb7 ${ne}`,value:(0,h.pctLabel)(S.walkInPct),detail:S.empty?void 0:`${S.walkIns} walk-in covers \xb7 ${S.bookings} booked covers \xb7 ${S.total} total`,change:(0,h.changeWords)((0,h.changePct)(S.walkInPct,G.walkInPct),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-noshow-pct",label:`No-show rate \xb7 ${ne}`,value:(0,h.pctLabel)(B.rate),detail:B.empty?void 0:`${B.count} no-show${1===B.count?'':'s'} out of ${B.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(B.rate,O.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-cancel-pct",label:`Cancellation rate \xb7 ${ne}`,value:(0,h.pctLabel)(U.rate),detail:U.empty?void 0:`${U.count} cancelled out of ${U.of} bookings`,change:(0,h.changeWords)((0,h.changePct)(U.rate,_.rate),x),empty:"No bookings in this period"}),(0,f.jsx)(I,{testID:"insights-covers",label:`Covers \xb7 ${ne}`,value:S.empty?null:String(S.total),detail:S.empty?void 0:'today'===x?E>0?`${E} more ${1===E?'cover':'covers'} booked for later today`:'No more bookings for later today':`${S.walkIns} walk-in \xb7 ${S.bookings} booked`,change:(0,h.changeWords)((0,h.changePct)(S.empty?null:S.total,G.empty?null:G.total),x),empty:"No covers yet in this period"}),(0,f.jsx)(I,{testID:"insights-repeat-pct",label:`Repeat guests \xb7 ${ne}`,value:(0,h.pctLabel)(ee.rate),detail:ee.empty?void 0:`${ee.count} of ${ee.of} identifiable seated or finished parties had visited before`,change:(0,h.changeWords)((0,h.changePct)(ee.rate,te.rate),x),empty:"Not enough guest phone or email details to measure repeat visits"}),(0,f.jsx)(I,{testID:"insights-reviews",label:`Reviews \xb7 ${ne}`,value:se.empty?null:`${se.avg} / 5`,detail:se.empty?void 0:`Average of ${se.count} published review${1===se.count?'':'s'}`,empty:"No published reviews in this period"}),(0,f.jsx)(I,{testID:"insights-tips",label:`Tips (team total) \xb7 ${ne}`,value:(0,h.moneyGbp)(q.tips),detail:null==q.tips?void 0:A&&null!=(0,h.tipsPctOfTakings)(q.tips,z.gross)?`${q.days} cash-up day${1===q.days?'':'s'} \xb7 ${(0,h.pctLabel)((0,h.tipsPctOfTakings)(q.tips,z.gross))} of takings`:`${q.days} cash-up day${1===q.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(q.tips,J.tips),x),empty:"No tips entered in this period"}),A?(0,f.jsxs)(n.default,{testID:"insights-takings-section",style:{gap:12},children:[(0,f.jsx)(I,{testID:"insights-takings",label:`Takings \xb7 ${ne}`,value:(0,h.moneyGbp)(z.gross),detail:null==z.gross?void 0:`From ${z.days} confirmed cash-up day${1===z.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(z.gross,F.gross),x),empty:"No takings entered in this period"}),(0,f.jsx)(I,{testID:"insights-sph",label:`Spend per head \xb7 ${ne}`,value:(0,h.moneyGbp)(H.sph),detail:null==H.sph?void 0:`Gross takings \xf7 ${H.covers} seated or finished covers, on ${H.days} cash-up day${1===H.days?'':'s'}`,change:(0,h.changeWords)((0,h.changePct)(H.sph,V.sph),x),empty:"No takings entered, so no spend per head"}),(0,f.jsx)(I,{testID:"insights-labour-pct",label:`Labour % of takings \xb7 ${ne}`,value:(0,h.pctLabel)(Y),detail:null!=Y?`${(0,h.moneyGbp)(Q)} confirmed labour \xf7 ${(0,h.moneyGbp)(z.gross)} takings`:void 0,change:(0,h.changeWords)((0,h.changePct)(Y,Z),x),empty:j||Object.keys(N).length?null==Q?'No confirmed paid hours with a rate in this period':'No takings entered, so no labour percentage':'Sign in to see labour against takings'})]}):(0,f.jsx)(n.default,{testID:"insights-takings-hidden",children:(0,f.jsx)(a.Muted,{center:!0,children:"Takings, spend per head and labour % of takings are only shown to owners and managers with See takings."})}),(0,f.jsx)(n.default,{testID:"insights-gp",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"GP % and food cost %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.weeklyGp})]})}),(0,f.jsx)(n.default,{testID:"insights-occupancy",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Table occupancy %"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.occupancy})]})}),(0,f.jsx)(n.default,{testID:"insights-top-dishes",children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{children:"Top dishes and channels"}),(0,f.jsx)(a.T,{weight:"semibold",children:h.UNAVAILABLE.topDishes})]})})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),u=_r(d[9]),y=_r(d[10]),b=_r(d[11]),v=_r(d[12]),f=_r(d[13]);const k=[{id:'today',label:'Today'},{id:'week',label:'This week'},{id:'month',label:'This month'}];function I({testID:e,label:t,value:s,detail:o,change:l,empty:r}){const c=!!l&&l.startsWith('Up'),h=!!l&&l.startsWith('Down');return(0,f.jsx)(n.default,{testID:e,children:(0,f.jsxs)(a.Card,{children:[(0,f.jsx)(a.Muted,{center:!0,children:t}),null==s?(0,f.jsx)(a.T,{testID:`${e}-empty`,weight:"semibold",center:!0,children:r}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a.T,{testID:`${e}-value`,weight:"semibold",size:u.font.hero,colour:u.colours.gold,center:!0,children:s}),o?(0,f.jsx)(a.Muted,{center:!0,children:o}):null,l?(0,f.jsx)(a.T,{testID:`${e}-change`,center:!0,colour:c?u.colours.goldLight:h?u.colours.muted:u.colours.text,children:l}):null]})]})})}},1501,[17,85,777,858,1006,876,1053,1456,946,804,1232,1233,1055,8]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{money:!0,label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{money:!0,label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{money:!0,label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1502,[805,1408,812,822,843,1503,1427,1475,1218,841,1254,946,1504,1506,1428,17,1096,1483,13,385,85,864,1272,777,858,876,851,866,1103,1243,863,804,1178,1055,1136,869,1446,853,1024,1151,847,845,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l,canWrite:p=!0}){const x=(0,c.useOrderAtTable)(e),f=(0,c.useNow)(15e3),w=(0,c.useStore)(e=>e.bookings),S=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),y=S.filter(i.waitingForStaff),v=S.filter(e=>j(e)&&!(0,i.waitingForStaff)(e)),k=S.filter(e=>!j(e)).slice(0,8),[T,$]=(0,s.useState)(null),[M,B]=(0,s.useState)(null),N=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},O=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,w));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},A=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),$(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},R=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",m(e.createdAt,f),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,j(e)&&p?T===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>A(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>$(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>N(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>O(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>$(e.id)})]}):j(e)&&!p?(0,b.jsx)(a.Muted,{children:"Ask a manager to accept, mark served or cancel this order."}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),x?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),M?(0,b.jsx)(a.Banner,{kind:"success",children:M}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(R,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",v.length,")"]}),v.length?v.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),k.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),k.map(e=>(0,b.jsx)(R,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const m=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},j=e=>!['served','collected','closed','cancelled'].includes(e.status)},1503,[843,17,85,777,845,851,1150,858,853,804,8]); +__d(function(g,_r,_i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,canWrite:u=!0,onOpenSettings:p}){const[x,y]=(0,t.useState)(null),[b,S]=(0,t.useState)(''),[k,v]=(0,t.useState)(null),[C,M]=(0,t.useState)(null),[T,B]=(0,t.useState)(!1),[R,P]=(0,t.useState)(''),[O,$]=(0,t.useState)(null),L=(0,c.staffServer)(),N=(0,n.can)('venue.settings'),[E,A]=(0,t.useState)(!1),[D,F]=(0,t.useState)(''),I=async e=>{if(x){A(!0),F('');try{await(0,c.saveSettings)({...x,cardOn:e}),y({...x,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';F(n),s.default.announceForAccessibility?.(n)}catch(e){P((0,o.plainError)(e))}A(!1)}},_=(0,t.useCallback)(()=>{L&&(0,c.readSettings)().then(y).catch(()=>{})},[L]);(0,t.useEffect)(()=>(_(),(0,c.watchLoyalty)(()=>{_(),M(e=>(e&&(0,c.staffCard)(e.id).then(M).catch(()=>{}),e))})),[_]);const z=async(e=b)=>{P('');try{const n=await(0,c.staffFind)(e);v(n),1===n.length&&M(n[0])}catch(e){P((0,o.plainError)(e))}},H=(0,t.useCallback)(e=>{B(!1),S((0,o.prettyCardNo)(e)),z(e)},[]);return L?(0,m.jsxs)(l.default,{style:{gap:10},children:[!x||x.cardOn||N?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),x&&N?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[x.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(x.cardOn?'On':'Off'),value:x.cardOn,disabled:E,onChange:e=>{I(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,p?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:p}):null]})}):null,x&&x.saved?(0,m.jsxs)(i.Muted,{children:[x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,x&&!x.saved&&N?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",x.stampsNeeded," stamps = ",x.reward||'reward not set',". At most ",x.maxPerDay," a day",x.gapMinutes?`, ${x.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:b,onChangeText:S,onSubmitEditing:()=>z(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:b.trim().length<2,onPress:()=>z(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:T?'Scanning\u2026':'Scan their card',onPress:()=>B(!0)}):null]}),T?(0,m.jsx)(h.CardScanner,{onCard:H,onClose:()=>B(!1)}):null,R?(0,m.jsx)(i.Banner,{kind:"warn",children:R}):null,k&&!k.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,k&&k.length>1?k.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>M(e)})]},e.id)):null]}),C?(0,m.jsx)(f,{card:C,settings:x,canRemove:r,canWrite:u,onChange:e=>{M(e),v(null)},onClose:()=>M(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),u&&O?(0,m.jsx)(j,{c:O,what:"One stamp."}):null,u?(0,m.jsx)(i.Button,{kind:"secondary",label:O?'Make another code':'Make a stamp code',disabled:!1===x?.cardOn,onPress:()=>{P(''),(0,c.staffCode)('stamp').then($).catch(e=>P((0,o.plainError)(e)))}}):null]}),u?(0,m.jsx)(w,{venue:e,onJoined:e=>{M(e),v(null)}}):null,(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,canWrite:r=!0,onChange:h,onClose:x}){const[y,f]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),M=async e=>{b(!0),f(null);try{await e()}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{b(!1),k(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:x})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),y?(0,m.jsx)(i.Banner,{kind:y.kind,children:y.text}):null,r?(0,m.jsx)(i.Button,{label:w?'Saving\u2026':'Add a stamp',disabled:w||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>M(async()=>{const n=await(0,c.staffStamp)(e.id);h(n),f({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}):(0,m.jsx)(i.Muted,{children:"Ask a manager to add a stamp or use a reward."}),r&&!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),S===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:w,onPress:()=>M(async()=>{const n=await(0,c.staffRedeem)(e.id);h(n),f({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>k(null)})]}):r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>k(e.id)}):null]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[r?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>M(async()=>C(await(0,c.staffCode)('link',e.id)))}):null,s?'remove'===S?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>M(async()=>{await(0,c.staffRemove)(e.id),h(null),x()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>k(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>k('remove')}):null]}),v?(0,m.jsx)(j,{c:v,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===S?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1504,[946,17,264,219,85,1272,777,1251,1254,804,1505,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1505,[17,219,85,777,1251,8]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e,canWrite:t=!0}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e,canWrite:t}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const m=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},f=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e,canWrite:t=!0}){const[s,a]=(0,n.useState)(''),[x,p]=(0,n.useState)(null),[b,y]=(0,n.useState)(''),[w,k]=(0,n.useState)((0,u.redeemKey)()),[S,T]=(0,n.useState)(null),[C,v]=(0,n.useState)(!1),P=(0,u.poundsToPence)(b);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:t?'Check a gift card or take it off the bill':'Check a gift card'}),(0,j.jsx)(r.Field,{label:"Gift card code",value:s,autoCapitalize:"characters",onChangeText:e=>{a(e),p(null),k((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:C?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:C||s.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{v(!0),T(null);try{const e=await(0,h.giftCheck)(s);p(e),e.found||T({kind:'warn',text:'No gift card with that code here.'})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}}),x?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(s)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(x.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[x.status]??x.status," \xb7 of ",(0,o.gbp)(x.initialPence),x.expiresAt?` \xb7 use by ${m(x.expiresAt)}`:'','wix'===x.source?' \xb7 old website bookings card':'']}),'active'===x.status&&t?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{money:!0,label:"Amount to take off \xa3",value:b,onChangeText:y,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:C?'Taking it off\u2026':P?`Take ${(0,o.gbp)(P)} off the card`:'Take it off the card',disabled:C||!P||P>x.balancePence,testID:"gift-redeem",onPress:async()=>{v(!0),T(null);try{const t=await(0,h.giftRedeem)(s,P,w,e);p({...x,...t,found:!0}),y(''),k((0,u.redeemKey)()),T({kind:'success',text:`${t.already?'Already taken: ':'Taken '}${(0,o.gbp)(t.redeemedPence)}. ${(0,o.gbp)(t.balancePence)} left on the card.`})}catch(e){T({kind:'warn',text:(0,c.plainError)(e)})}finally{v(!1)}}})]}):'active'!==x.status||t?null:(0,j.jsx)(r.Muted,{children:"Ask a manager to take an amount off the card."})]}):null,(0,j.jsx)(f,{m:S})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{money:!0,label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",m(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(f,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const W=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!W,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:W}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{money:!0,label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{money:!0,label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${m(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(f,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",m(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(f,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1506,[805,1408,17,85,777,851,1251,1252,1253,946,1254,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o,rid:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o,rid:u})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1507,[17,1205,1153,1206,1215,1055,1169,847,856,992,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1508,[17,85,777,946,863,804,8]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["CoverCharge confirms every booking and takeaway order by email. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest. If the guest booked through the website, the website may also send its own confirmation, including by text."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1509,[813,812,822,17,219,385,85,777,1220,858,1490,848,1222,1016,804,1025,1055,8]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OnlineBookingRulesPage=function({go:e}){const{r:s,rid:g,role:h}=(0,k.useCtx)(6e4),p='owner'===h||'manager'===h,x=s.settings,b=(0,r.bookingRulesOf)(s),j=(0,o.usePlan)(g),f=(j?.areas??[]).map(e=>e.name),v=e=>{p&&l.useStore.getState().updateSettings(g,e)},T=e=>v({bookingRules:{...x.bookingRules??{},...b,...e}}),P=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],S=(0,u.onlinePartyBounds)(s),R=(0,d.depositOf)(x),M=x.reservables??(0,i.reservablesOf)(s),O=(0,r.accessGuideOf)(s),[A,I]=(0,t.useState)(null),B=(e,t)=>T({largeGroups:b.largeGroups.map((s,n)=>n===e?{...s,...t}:s)});return(0,y.jsxs)(n.default,{style:{gap:10},testID:"online-booking-rules",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Preview",children:"These are the rules the online booking page follows. Changes are saved to your venue settings. Nothing is sent to guests from here."}),p?null:(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can change these."}),A?(0,y.jsx)(a.Muted,{center:!0,testID:"rules-msg",children:A}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:1,title:"Party size and dates"}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, from"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-min",value:S.min,min:1,max:S.max,onChange:e=>v({onlinePartyMin:e}),label:"online party from"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Online party size, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-party-max",value:S.max,min:S.min,max:100,onChange:e=>v({onlinePartyMax:e}),label:"online party up to"})]}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Taken without checking, up to"}),(0,y.jsx)(a.Stepper,{testID:"rules-auto",value:x.autoAcceptUpTo??7,min:1,max:30,onChange:e=>v({autoAcceptUpTo:e}),label:"auto-accept online bookings up to"})]}),(0,y.jsxs)(a.Muted,{center:!0,children:[(0,c.bookAheadUnlimited)(s)?'Full calendar: guests can pick any future date up to a year ahead.':`Guests can book up to ${(0,c.bookAheadDays)(s)} days ahead.`," Change this in Booking settings."]})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:2,title:"Large groups"}),(0,y.jsx)(a.Muted,{center:!0,children:"Groups in these sizes are placed on joined tables. Staff can still move them."}),b.largeGroups.map((e,t)=>(0,y.jsxs)(n.default,{style:{gap:4,alignItems:'center'},testID:`rules-group-${t}`,children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:(0,r.largeGroupLine)(e)}),(0,y.jsxs)(a.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Stepper,{value:e.from,min:1,max:e.to,onChange:e=>B(t,{from:e}),label:`group ${t+1} from`}),(0,y.jsx)(a.Stepper,{value:e.to,min:e.from,max:100,onChange:e=>B(t,{to:e}),label:`group ${t+1} up to`})]}),(0,y.jsx)(a.Field,{label:"Tables, joined (e.g. 14+15)",value:e.tables.join('+'),editable:p,onChangeText:e=>B(t,{tables:e.split(/[+,\s]+/).map(e=>e.trim()).filter(Boolean)})}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove this group size",onPress:()=>T({largeGroups:b.largeGroups.filter((e,s)=>s!==t)})}):null]},t)),b.largeGroups.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No large-group tables set."}),p?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Add a group size",onPress:()=>{const e=b.largeGroups[b.largeGroups.length-1],t=e?e.to+1:8;T({largeGroups:[...b.largeGroups,{from:t,to:t+1,tables:[]}]})}}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:3,title:"Areas booked online"}),(0,y.jsx)(a.Muted,{center:!0,children:"Tap an area to stop online bookings there. Staff can still seat and book every area."}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>{const t=b.offlineAreas.some(t=>t.toLowerCase()===e.toLowerCase());return(0,y.jsx)(a.Chip,{testID:`rules-area-${e}`,label:e,sub:t?'Not online':'Online',selected:!t,disabled:!p,onPress:()=>T({offlineAreas:P(b.offlineAreas,e)})},e)})}),(0,y.jsx)(a.Field,{label:"Why (guests see this)",value:b.offlineReason,editable:p,onChangeText:e=>T({offlineReason:e})})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:4,title:"Dogs"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-dog-line",children:(0,r.dogRuleLine)(b,s.phone)}),(0,y.jsx)(a.T,{center:!0,size:14,children:"Pet dogs allowed in"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogAreas.includes(e),disabled:!p,onPress:()=>T({dogAreas:P(b.dogAreas,e)})},e))}),(0,y.jsx)(a.T,{center:!0,size:14,children:"On the day only, weather permitting"}),(0,y.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:f.map(e=>(0,y.jsx)(a.Chip,{label:e,selected:b.dogWeatherAreas.includes(e),disabled:!p,onPress:()=>T({dogWeatherAreas:P(b.dogWeatherAreas,e)})},e))}),(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{children:"Most people online with a dog"}),(0,y.jsx)(a.Stepper,{testID:"rules-dog-max",value:b.dogMaxParty,min:0,max:20,format:e=>e?String(e):'No limit',onChange:e=>T({dogMaxParty:e}),label:"most people online with a dog"})]}),(0,y.jsx)(a.Muted,{center:!0,children:"Assistance dogs are always welcome anywhere and never count towards this."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:5,title:"Requested table"}),(0,y.jsx)(a.Toggle,{label:"Guests can request a table",value:!1!==x.tableRequests,disabled:!p,onChange:e=>v({tableRequests:e})}),(0,y.jsx)(a.Field,{label:"What guests are told",value:b.tableRequestNote,editable:p,onChangeText:e=>T({tableRequestNote:e}),multiline:!0}),b.tableRequestNote!==r.TABLE_REQUEST_NOTE&&p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Back to the usual words",onPress:()=>T({tableRequestNote:r.TABLE_REQUEST_NOTE})}):null,(0,y.jsx)(a.Muted,{center:!0,children:"Requests show in gold on the booking in Managers, the Display and the kitchen."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:6,title:"Access needs"}),(0,y.jsx)(a.Muted,{center:!0,children:"Shown when a guest asks for step-free access, has a wheelchair user or brings an assistance dog. The booking is flagged \u267f for staff."}),(0,y.jsx)(a.Field,{label:"Step-free entry guide",value:x.accessStatement??O,editable:p,multiline:!0,onChangeText:e=>v({accessStatement:e}),testID:"rules-access"})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:7,title:"Deposits and pre-orders"}),(0,y.jsx)(a.Muted,{center:!0,testID:"rules-deposit-line",children:R.on&&R.perPersonPence>0?`${w(R.perPersonPence)} per adult for ${R.fromParty} or more adults. Children don't count and don't pay. Staff can waive it for regulars.`:'Group deposits are off.'}),M.filter(e=>e.active).map(e=>(0,y.jsxs)(a.Muted,{center:!0,children:[e.name,e.serves&&!/\(serves/i.test(e.name)?` (serves ${2===e.serves?'two':e.serves})`:'',", ",w(e.price),": ",e.payOnNight||!e.depositPence?'no deposit, paid on the night':`${w(e.depositPence)} deposit per item, through website bookings`]},e.id)),(0,y.jsx)(a.Muted,{center:!0,children:"Pre-orders and deposits show on the booking for staff and the kitchen."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Change amounts in Advanced settings",onPress:()=>e('more','advanced')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:8,title:"Email and marketing"}),(0,y.jsx)(a.Toggle,{label:"Email needed to book or order online",value:b.emailRequiredOnline,disabled:!p,onChange:e=>T({emailRequiredOnline:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"Online pages only. Bookings made by staff, walk-ins and the Display keep email optional."}),(0,y.jsx)(a.Toggle,{label:"Offer the marketing tick (always unticked to start)",value:b.marketingOptIn,disabled:!p,onChange:e=>T({marketingOptIn:e})}),(0,y.jsx)(a.Field,{label:"Marketing tick words",value:b.marketingWords,editable:p,onChangeText:e=>T({marketingWords:e}),multiline:!0}),(0,y.jsx)(a.Muted,{center:!0,children:"Only guests who ticked it can be sent marketing (UK GDPR and PECR)."}),e?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Marketing opt-ins \u203a",onPress:()=>e('more','optins')}):null]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:9,title:"Allergies"}),(0,y.jsx)(a.Toggle,{label:"Guests tick to confirm the allergy information",value:b.allergyConfirm,disabled:!p,onChange:e=>T({allergyConfirm:e})}),(0,y.jsx)(a.Field,{label:"Tick words",value:b.allergyConfirmWords,editable:p,onChangeText:e=>T({allergyConfirmWords:e})}),(0,y.jsx)(a.Muted,{center:!0,children:"The allergy question always comes first, and staff see the guest's answer and tick on every booking."})]}),(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(C,{n:10,title:"Notes example"}),(0,y.jsx)(a.Field,{label:"Shown in the empty notes box",value:b.notesPlaceholder,editable:p,onChangeText:e=>T({notesPlaceholder:e}),testID:"rules-notes"})]}),p?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Put every rule back to the defaults",onPress:()=>{v({bookingRules:void 0}),I('Online booking rules are back to the defaults.')}}):null]})},_e.supervisorNow=v,Object.defineProperty(_e,"optinsAllowed",{enumerable:!0,get:function(){return T}}),_e.MarketingOptInsPage=function(){const{rid:e,role:s}=(0,k.useCtx)(6e4),o=T(s),i=(0,l.useBookings)(e),d=(0,l.useOrders)(e),u=(0,x.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[c,h]=(0,t.useState)(null),[p,w]=(0,t.useState)(null);(0,t.useEffect)(()=>{if(!o||!u||!(0,j.isSupabaseConfigured)())return;let e=!0;try{(0,b.getSupabase)().rpc('marketing_optins',{p_venue:u}).then(({data:t,error:s})=>{e&&!s&&Array.isArray(t)&&h(t.map(e=>({email:e.email,name:e.name,optedInAt:e.opted_in_at,lastBooking:e.last_booking??'',bookings:e.bookings??0,source:e.source??''})))},()=>{})}catch{}return()=>{e=!1}},[o,u]);const C=(0,t.useMemo)(()=>(0,r.optedInGuests)([...i,...d.map(e=>({email:e.email,name:e.customerName,date:e.createdAt.slice(0,10),source:'takeaway',marketingOptIn:e.marketingOptIn,marketingOptInAt:e.marketingOptInAt}))]),[i,d]);if(!o)return(0,y.jsx)(a.Muted,{center:!0,children:"Only managers and owners can see the marketing list."});const v=c??C,P=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':t.toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric'})};return(0,y.jsxs)(n.default,{style:{gap:10},testID:"marketing-optins",children:[(0,y.jsx)(a.Banner,{kind:"demo",title:"Nothing is sent",children:"This is the list of guests who ticked the marketing box. CoverCharge doesn't send marketing. Download the list for your own mail tool."}),(0,y.jsx)(a.Muted,{center:!0,children:"Only these guests may be sent news and offers (UK GDPR and PECR). If a guest later books with the box left unticked, they come off the list."}),(0,y.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(a.Badge,{kind:"gold",label:`${v.length} opted in`}),(0,y.jsx)(a.Badge,{kind:"neutral",label:c?'From the server':'From this device'})]}),v.map(e=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"semibold",center:!0,children:e.name||'Guest'}),(0,y.jsx)(a.Muted,{center:!0,children:e.email}),(0,y.jsxs)(a.Muted,{center:!0,size:13,children:["Opted in ",P(e.optedInAt),e.bookings?` \xb7 ${e.bookings} booking${1===e.bookings?'':'s'}`:'',e.lastBooking?` \xb7 last ${e.lastBooking.split('-').reverse().join('/')}`:'']}),c&&u&&(0,j.isSupabaseConfigured)()?(0,y.jsx)(a.Button,{small:!0,kind:"ghost",label:"Guest unsubscribed: take off the list",accessibilityLabel:`${e.name||'Guest'} unsubscribed: take off the marketing list`,onPress:()=>{(0,b.getSupabase)().rpc('marketing_optout',{p_venue:u,p_email:e.email}).then(({error:t})=>{t?w('That did not save. Try again.'):(h(t=>(t??[]).filter(t=>t.email!==e.email)),w(`${e.email} is off the list.`))},()=>w('That did not save. Try again.'))}}):null]},e.email)),v.length?null:(0,y.jsx)(a.Muted,{center:!0,children:"No one has opted in yet."}),v.length?(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Download CSV",testID:"optins-csv",onPress:()=>{(0,g.downloadText)('marketing-opt-ins.csv',(0,r.optedInCsv)(v)),w('CSV downloaded. Keep it private.')}}):null,p?(0,y.jsx)(a.Muted,{center:!0,children:p}):null,(0,y.jsx)(a.T,{size:13,colour:f.colours.muted,center:!0,children:"Every email you send must include an easy way to unsubscribe."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(_d[2]),l=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),g=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),f=_r(_d[16]),k=_r(_d[17]),y=_r(_d[18]);const w=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,C=({n:e,title:t})=>(0,y.jsxs)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:[e,". ",t]});function v(){if('supervisor'===String(x.useSync.getState().role||''))return!0;const e=p.useSession.getState().meId;return!!e&&h.useOwner.getState().staff.some(t=>t.id===e&&'Supervisor'===t.level)}const T=e=>('owner'===e||'manager'===e)&&!v()},1510,[17,85,777,858,996,1077,1053,841,1103,1243,889,876,966,946,892,935,804,1055,8]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderSheetSettings=function(){const e=(0,o.useOwner)(e=>e.site),u=(0,i.useSheets)(e),[p,m]=(0,t.useState)(null);return p?(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===p.id)?`Edit ${p.name}`:'New supplier'}),(0,c.jsx)(b,{rid:e,s:p,onDone:()=>m(null)})]}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,c.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,c.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,c.jsxs)(s.Card,{children:[(0,c.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,c.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,c.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,c.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,c.jsx)(s.Row,{wrap:!0,gap:8,children:(0,c.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var t=r(_d[0]),l=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),o=r(_d[4]),i=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]),c=r(_d[10]);const m=['online','phone','text','whatsapp','tbc'];function x({label:e,value:t,onChange:l}){return(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,c.jsx)(s.Chip,{label:e,selected:t.includes(n),onPress:()=>l(t.includes(n)?t.filter(e=>e!==n):[...t,n].sort())},e))})]})}function b({rid:e,s:l,onDone:o}){const d=(0,i.useOrderSheets)(e=>e.upsert),b=(0,i.useOrderSheets)(e=>e.remove),[y,f]=(0,t.useState)(l),[j,C]=(0,t.useState)(l.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[v,w]=(0,t.useState)(l.priceCapPerKg?(l.priceCapPerKg/100).toFixed(2):''),[T,D]=(0,t.useState)(!1),P=e=>f(t=>({...t,...e}));return(0,c.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,c.jsx)(s.Field,{label:"Supplier name",value:y.name,onChangeText:e=>P({name:e})}),(0,c.jsx)(s.Field,{label:"What they supply",value:y.goods,onChangeText:e=>P({goods:e})}),(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,c.jsx)(s.Row,{wrap:!0,gap:6,children:m.map(e=>(0,c.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:y.method===e,onPress:()=>P({method:e})},e))})]}),'text'===y.method||'whatsapp'===y.method||'phone'===y.method?(0,c.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:y.number,keyboardType:"phone-pad",onChangeText:e=>P({number:e})}):null,'online'===y.method?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:y.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>P({url:e.trim()})}),(0,c.jsx)(s.Field,{label:"Button label",value:y.urlLabel??'',placeholder:"Open website",onChangeText:e=>P({urlLabel:e})})]}):null,(0,c.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:y.contact??'',onChangeText:e=>P({contact:e})}),(0,c.jsx)(x,{label:"Delivery days",value:y.deliveryDays,onChange:e=>P({deliveryDays:e})}),(0,c.jsx)(x,{label:"Order days (a reminder shows in the Head Chef app)",value:y.orderDays,onChange:e=>P({orderDays:e})}),(0,c.jsxs)(s.Row,{gap:10,children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:y.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>P({cutoff:e})})}),(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(s.Field,{money:!0,label:"Price cap \xa3/kg (optional)",value:v,keyboardType:"decimal-pad",onChangeText:w})})]}),(0,c.jsx)(s.Field,{label:"Reminder text (optional)",value:y.reminder,onChangeText:e=>P({reminder:e})}),(0,c.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:y.frequency,onChangeText:e=>P({frequency:e})}),y.priceCapPerKg||v?(0,c.jsx)(s.Field,{label:"Seller",value:y.seller,onChangeText:e=>P({seller:e})}):null,(0,c.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:C}),(0,c.jsx)(s.Field,{label:"Notes for the chef",value:y.notes,multiline:!0,onChangeText:e=>P({notes:e})}),(0,c.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,c.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const t=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,t)=>{const[n,s]=e.split('|').map(e=>e.trim()),o=l.items.find(e=>e.name===n);return{id:o?.id??`${y.id}-i${t}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*((0,p.parseMoneyInput)(v)??NaN));d(e,{...y,items:t,priceCapPerKg:n>0?n:0,placeholder:y.placeholder&&'tbc'===y.method}),o()},disabled:!y.name.trim()}),(0,c.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:o}),T?(0,c.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{b(e,l.id),o()}}):(0,c.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>D(!0)})]})]})}},1511,[17,385,85,777,876,998,851,999,804,840,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1512,[17,219,385,85,409,777,804,1367,857,1371,863,946,1372,1055,8]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1513,[820,943,1444,17,219,85,777,816,876,942,998,944,946,1514,804,880,1157,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1514,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1515,[17,85,777,804,1423,1503,1055,8]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1516,[812,1031,779,17,385,85,777,876,1467,1517,1518,1519,804,1055,8]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return o}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],a=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, type \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from your suppliers',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add supplier links for this venue, with an account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add against a supplier (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'display-every-plan',kind:'faq',topic:'Settings',title:'Which plans include the customer app?',keywords:['customer app','guest app','download','phone','plan','package','superpro','epos','early adopter'],body:'The downloadable customer app for guests\u2019 phones comes with every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. SuperPro is everything in Pro, plus EPOS (tills, kitchen displays and waiter pads) and a full venue app for staff and customers. 1-year contract. Once your EPOS is connected, everything works together as one system, giving you insights on live sales and takings, GP changes and every edited clock-in. The early adopter offer (first 50 venues) is every Full Restaurant Pro feature: one-month free trial, then a 12-month contract at \xa349 a month + VAT if applicable, per venue, then rolling monthly at \xa399 with one month\u2019s notice. Every plan has free customer support for the length of your subscription and free over-the-air updates. All prices + VAT if applicable, per venue.'},{id:'ota-free',kind:'faq',topic:'Settings',title:'Do app updates cost extra?',keywords:['update','updates','over-the-air','ota','new version','upgrade','cost','free','plan'],body:'Free over-the-air updates, on every plan: Customer & Takeaway App, Full Restaurant Pro App, SuperPro and the early adopter offer. Over-the-air updates will be available free of charge to the app.'},{id:'owner-desktop-plan',kind:'faq',topic:'Settings',title:'Which plans include the owner desktop version?',keywords:['desktop','computer','mac','pc','owner desktop','ecosystem','plan','package','superpro','early adopter'],body:'The owner desktop version \u2014 the complete ecosystem on Mac or PC \u2014 comes with Full Restaurant Pro App, SuperPro and the early adopter offer. It is not included with Customer & Takeaway App. It is an installable wide-screen web app that uses the same data, sign-ins and permissions as the phone app. Open it from the CoverCharge website\u2019s /desktop page, or from More \u203a Use on a computer on your phone. On SuperPro it comes with full ecosystem insights once your EPOS is connected: insights on live sales and takings, GP changes and every edited clock-in.'},{id:'confirm-by-email',kind:'faq',topic:'Bookings',title:'How are bookings and takeaway orders confirmed?',keywords:['confirmation','confirm','email','text','sms','booking','takeaway','wix'],body:'CoverCharge confirms guest bookings and takeaway orders by email. CoverCharge itself does not confirm by text. If a booking was made through the website, the website may also text the guest its own confirmation. That isn\u2019t CoverCharge.'},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for the length of your subscription. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant shows you exactly what it will do and waits for you to tap Confirm. Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Deluxe Seafood Platter (serves two) (1 crab + 1 lobster, \xa3165, \xa325 deposit per platter) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Enter the cash up, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Enter the cash up, or upload a spreadsheet',keywords:['cash up','paid out','spreadsheet','csv','excel','xlsx','sheet','gross','card','cash','tips','takings','drawer'],body:'In Cash up & sales tap Enter the cash up and type the figures (Z total, card, cash, paid outs, tips, and gross if you have it). In Paid out, add a line for each amount taken from the till \u2014 for example lobsters or supermarket shopping \u2014 with the amount, an optional note, and your name. The paid-out total comes off the expected cash in the drawer. Check every figure, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. You can export cash ups as a spreadsheet from Recent cash ups.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay and do not count towards the number that needs one: a table of 8 with 3 children pays nothing; a table of 6 adults, or 7 with 1 child, pays for 6), the smallest number of adults that pays one (6 or more adults at The Anchorage), whether it is refundable and up to how many hours before, and the words guests see. Staff can waive a deposit. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Enter the cash up. Type each figure; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Add any cash paid out of the till (lobsters, supermarket shopping, and the like) in the Paid out section: each line has what it was for, the amount, an optional note and who entered it. The total reduces the expected cash in the drawer. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs if they are allowed to see takings. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'cashup-by-hand'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],o=t=>a.find(a=>a.id===t)},1517,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1518,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1519,[1520,1098,843,1521,1522,876,858,996,1467,1517,1518,1524,1523,1526,1527,994,995]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1520,[1062,1061,1021]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return A}}),e.resolveTable=x,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return E}}),e.findBooking=P,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return $e}});var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),y=_r(_d[16]),k=_r(_d[17]),w=_r(_d[18]);const v=t=>{const[n,a,r]=t.split('-').map(Number);return new Date(n,a-1,r).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},S=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock)}catch{return new Date}},$=(t,n)=>n.test(t),C=t=>t.who??('display'===t.app?'Display':'Assistant');function N(t){if('display'===t.app)return!0;if((0,d.isKitchenViaDisplay)())return!0;const n=m.useOwner.getState().staff.find(n=>n.id===t.whoId);return(0,o.canSeatClearFinish)({role:n?.role??t.role,ownerAccess:n?.ownerAccess,managerAccess:n?.managerAccess})}const I={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},L=t=>null==t||''===t?void 0:'number'==typeof t?t:I[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),_=['owner','staff','display'],q=['owner','staff','chef','display'],O=['staff'],D=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,A=t=>{const n=t.match(D);return n?String(L(n[1])??n[1]).toUpperCase():void 0};function x(t,n){const a=String(n??'').replace(/^tables?\s+/i,'').trim();if(!a)return;const r=String(L(a)??a).toLowerCase(),o=(0,u.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(u.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===r)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===r)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===r.replace(/[^0-9a-z]/g,''))}const T=(t,n)=>u.useFloor.getState().live[t]?.[n]??{},j=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),M=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!j.has(t)),E=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let a=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&a<12&&(a+=12),!n[3]&&a>=1&&a<=11&&(a+=12),`${String(a).padStart(2,'0')}:${n[2]??'00'}`};function P(t,n,a,r,o){const i=String(a??'').toLowerCase(),s=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status)&&!/walk-?in/i.test(a.name??'')),d=c.useStore.getState().bookings.filter(a=>a.restaurantId===t&&a.date===n&&r.includes(a.status));if(!i&&!o)return;const l=d.find(t=>t.ref&&i.includes(t.ref.toLowerCase()));if(l)return l;const b=M(i),h=s.filter(t=>M(t.name).some(t=>b.includes(t)));if(1===h.length)return h[0];if(o){const t=d.filter(t=>(0,u.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=h.length?t.filter(t=>h.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const p=/\d/.test(i.replace(D,''))?E(i.replace(D,'')):null;if(p){const t=(h.length?h:s).filter(t=>t.time===p);if(1===t.length)return t[0]}return h.length?h.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const z=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,F=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],R=t=>({booking:t,table:A(t)}),B='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function H(t,n,a,r,i,s,d,c=""){return{id:t,apps:_,title:n,risk:'change',params:F,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${c}`,match:t=>$(t,i)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`${s}: ${z(a)}?${c}`:B},run:async(t,n)=>{const i=P(n.rid,n.today,t.booking,r,x(n.rid,t.table)??(t.table?String(t.table):void 0));return i?'finished'!==a&&'seated'!==a||N(n)?(await l.repo.bookings.setStatus(i.id,a),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===a?'marked as a no-show':'cancelled'===a?'cancelled':'finished'===a?'finished':a}.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const U=(t,n)=>(0,u.tablesOf)(n).forEach(n=>u.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),W={id:'seat_booking',apps:_,title:'Seat a booking',risk:'change',params:F,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!$(t,/\b(seat|sit)\b/)||$(t,/\b(walk.?in|walkin|no booking)\b/)||$(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?$(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']),o=x(n.rid,t.table)??a?.table;if(!a)return B;const i=o?T(n.rid,(0,u.tablesOf)(o)[0]):{};return`Seat ${a.name}, ${a.partySize} at ${a.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,r.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,r.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,r.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!N(n))return'Nothing changed. '+o.SEAT_CLEAR_HINT;const r=x(n.rid,t.table);return t.table&&!r?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(r&&r!==a.table&&await l.repo.bookings.update(a.id,{table:r}),await l.repo.bookings.setStatus(a.id,'seated'),U(n.rid,r??a.table),`Done: ${a.name} seated${r??a.table?` at table ${r??a.table}`:''}.`)}},G={id:'finish_booking',apps:_,title:'Finish a table (party left)',risk:'change',params:F,keywords:[],description:'Mark a seated party as finished. The table is then marked as needing clearing. A 15-second Undo is offered.',match:t=>$(t,/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/)?7:0,parse:R,preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?`Mark finished: ${z(a)}? The table is then marked as needing clearing.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['seated'],x(n.rid,t.table)??(t.table?String(t.table):void 0));return a?N(n)?(await(0,i.finishBookingNow)(n.rid,a),(0,s.offerFinishUndo)({rid:n.rid,bookings:[a],name:a.name,table:a.table,big:!0}),`Done: ${a.name} finished.`):'Nothing changed. '+o.SEAT_CLEAR_HINT:"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}},V=H('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),K=H('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),Y={id:'move_booking',apps:_,title:'Move a booking to another table',risk:'change',params:[F[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>$(t,/\b(move|put|switch|change)\b/)&&$(t,/\btables?\b/)&&!$(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(D.source,'gi'))],a=n[n.length-1];return{booking:t,table:a?String(L(a[1])??a[1]).toUpperCase():void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),o=x(n.rid,t.table);return a?o?'finished'===a.status?`${a.name} is finished. Seat them at table ${o}?`:`Move ${z(a)} to table ${o}?${T(n.rid,o).stage||T(n.rid,o).blocked?` ${(0,r.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:B},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending','seated','finished']),r=x(n.rid,t.table);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!r)return'Nothing changed: I couldn\u2019t find that table on the plan.';if('finished'===a.status)return await(0,s.restoreFinishedToTable)(n.rid,a,[r]),`Done: ${a.name} seated again at table ${r}.`;const o=a.table;return await l.repo.bookings.update(a.id,{table:r,tableSetHere:!0}),'seated'===a.status&&((0,u.tablesOf)(o).forEach(t=>u.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),U(n.rid,r)),`Done: ${a.name} moved to table ${r}.`}},J={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[F[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>$(t,/\b(change|make it|now|instead|update|actually)\b/)&&$(t,/\b(booking|reservation|party)\b/)&&$(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),a=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),r=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:a&&/people|covers|guests|pax|party|for/.test(n)&&!r?.[1]?.startsWith(a[1])?L(a[1]):void 0,time:r?E(r[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['confirmed','pending']);return a?t.time||t.covers?`Change ${z(a)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${a.name}\u2019s booking? Say the new time or number of people.`:B},run:async(t,a)=>{const r=P(a.rid,a.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const o=L(t.covers);if(!(null==t.covers||o&&(0,n.validParty)(o)))return`Nothing changed: ${n.PARTY_RULE}`;const i=t.time?E(String(t.time)):null;return o||i?(await l.repo.bookings.update(r.id,{...o?{partySize:o}:{},...i?{time:i}:{}}),`Done: ${r.name} is now ${o??r.partySize} at ${i??r.time}.`):'Nothing changed.'}},Q={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[F[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>$(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&$(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${a.name}, ${a.partySize} on ${v(a.date)} at ${a.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const a=P(n.rid,n.today,t.booking,['pending'])??c.useStore.getState().bookings.find(a=>a.restaurantId===n.rid&&'pending'===a.status&&M(a.name).some(n=>M(String(t.booking)).includes(n)));return a?(await l.repo.bookings.decide(a.id,'declined'===t.outcome?'declined':'confirmed',C(n)),`Done: ${a.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},X=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Z={id:'table_cleared',apps:_,title:'Mark a table cleared',risk:'change',params:X,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} cleared and free?${T(n.rid,a).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!1,stage:void 0}),`Done: table ${a} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},ee={id:'table_needs_clearing',apps:_,title:'Mark a table as needing clearing',risk:'change',params:X,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>$(t,/\btables?\b/)&&$(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:A(t)}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Mark table ${a} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{dirty:!0,stage:void 0}),`Done: table ${a} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},te={id:'block_table',apps:_,title:'Block or unblock a table',risk:'change',params:[...X,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>$(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&$(t,/\btables?\b/)&&!$(t,/\barea\b/)?8:0,parse:t=>({table:A(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const a=x(n.rid,t.table);return a?`${'no'===t.blocked?'Unblock':'Block'} table ${a}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table);return a?(u.useFloor.getState().setLive(n.rid,a,{blocked:'no'!==t.blocked}),`Done: table ${a} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},ne={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},ae={id:'table_stage',apps:_,title:'Set a table\u2019s course',risk:'change',params:[...X,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>$(t,/\btables?\b/)&&$(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:A(t),stage:n?ne[n[1]]:void 0}},preview:(t,n)=>{const a=x(n.rid,t.table);return a?`Set table ${a} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const a=x(n.rid,t.table),r=ne[String(t.stage??'').toLowerCase()];return a&&r?(u.useFloor.getState().setLive(n.rid,a,{stage:r,dirty:!1}),`Done: table ${a} is on ${r}.`):'Nothing changed: say the table and mains, dessert or bill.'}},re=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),oe=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(b.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,h.isRoastItem)(t))),ie=t=>(b.useShellStore.getState().items[t]??[]).filter(t=>t.active),se=(t,n)=>{const a=String(n??'').toLowerCase();return ie(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(a)))},de={id:'shellfish_count',apps:q,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!$(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!oe(t)||$(t,/\b(allerg|contain|chat|message|tell|text|post)/)||re(t)||!$(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,a)=>{const r=n.toLowerCase(),o=r.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(r)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(r)?'count':'sold',s=se(a.rid,r);return s&&(0,t.fishInStone)(a.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:L(o[1]):1,mode:i}},preview:(n,r)=>{const o=se(r.rid,n.item);if(!o||'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||!Number.isInteger(2*a))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,s=(0,t.fromStone)(a,o.unit),d='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(a)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,d),o.unit))}?`}const i=L(n.qty)??0,s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,h.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,h.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,h.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,h.fmtCount)(s)}, after ${(0,h.fmtCount)(Math.max(0,d))})?`},run:(n,r)=>{const o=se(r.rid,n.item);if(o&&'chef'===r.app&&!(0,a.chefCanSee)(r.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(r.rid,o)){const a=(0,t.parseStoneAmount)(n.qty??'');if(null==a||a<0||a>500||!Number.isInteger(2*a))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(a,o.unit),s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+d<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(d&&b.shellfish.append({rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner',delta:d,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+d,o.unit))} left.`)}const i=L(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,b.venueCounts)(b.useShellStore.getState(),r.rid)[o.key]??0,d={rid:r.rid,kind:o.key,by:C(r),app:r.app??'owner'};return'count'===n.mode?(i!==s&&b.shellfish.append({...d,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,h.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(b.shellfish.append({...d,delta:i,reason:'delivery'}),`Done: ${(0,h.fmtCount)(i)} in. ${(0,h.fmtCount)(s+i)} now.`):s($(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||oe(t))&&re(t)&&!$(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:se(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,r)=>{const o=(0,b.venueCounts)(b.useShellStore.getState(),r.rid),i=se(r.rid,n.item),s=(i?[i]:ie(r.rid).filter(t=>!(0,h.isRoastItem)(t)||(0,h.isSundayIn)(new Date))).filter(t=>'chef'!==r.app||(0,a.chefCanSee)(r.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(r.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,h.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},ce={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ue=(t,n)=>{const a=String(n??'').toLowerCase(),r=c.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return r.find(t=>t.ref&&a.includes(t.ref.toLowerCase()))??r.find(t=>{const n=a.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=r.filter(t=>M(t.customerName??'').some(t=>M(a).includes(t)));return 1===t.length?t[0]:void 0})()},be={id:'order_status',apps:q,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>$(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&$(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!$(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const a=ue(n.rid,t.order);return a?`Mark order ${a.ref} for ${a.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const a=ue(n.rid,t.order),r=ce[String(t.status)];if(!a||!r)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===r){return await l.repo.orders.accept(a.id,C(n))?`Done: order ${a.ref} accepted.`:`Order ${a.ref} was already accepted.`}return await l.repo.orders.setStatus(a.id,r,C(n)),`Done: order ${a.ref} is ${r}.`}},he={id:'order_list_add',apps:q,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>$(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!$(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:L(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const a=p.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),r=String(t.list??'').toLowerCase(),o=r&&a.find(t=>t.name.toLowerCase().includes(r))||a[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const a=p.useOrderLists.getState(),r=a.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&r.find(t=>t.name.toLowerCase().includes(o))||r[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(L(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:C(n)},c=a.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return c?(a.bump(c.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(a.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},pe={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function me(t,n,a){return{id:t,apps:O,title:pe[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${pe[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>$(t,a)?8:0,preview:()=>`${pe[n]} now?`,run:async(t,a)=>{if(!a.whoId)return'Sign in to the Staff app first.';const r=S().toISOString(),o=await(0,f.clockAction)(n,{rid:a.rid,staffId:a.whoId,date:a.today,at:r});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(r).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ge=me('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),fe=me('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),ye=me('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),ke=me('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),we=t=>{const n=m.useOwner.getState().staff,a=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>M(a).includes(t)))?.id},ve=(t,n)=>{if(!(0,y.hasRecipeCards)())return;const a=M(String(n??''));let r;for(const n of(0,y.recipeCards)().list(t)){const t=M(n.dish).filter(t=>a.includes(t)).length;t&&t>(r?.s??0)&&(r={c:n,s:t})}return r?.c},Se=t=>{const n=w.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},$e=[W,G,V,K,Y,J,Q,Z,ee,te,ae,de,le,be,he,ge,fe,ye,ke,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>$(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&$(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),a=m.useOwner.getState().staff.find(t=>t.active&&M(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:a?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status),o=n.staff.find(t=>t.id===a)?.name.replace(' (example)','');return r?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${v(r.from)}${r.to!==r.from?` to ${v(r.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=m.useOwner.getState(),a=we(t.staffId),r=n.leave.find(t=>t.staffId===a&&'pending'===t.status);return r?(n.setLeave(r.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>$(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?`${a.dish} can\u2019t be signed off yet: ${r}`:`Sign off ${a.dish}? Allergens: ${Se(a.allergens)}.`},run:async(t,n)=>{const a=ve(n.rid,t.dish);if(!a)return'Nothing changed: I couldn\u2019t find that recipe card.';const r=(0,k.signOffBlock)(a);return r?'Nothing changed: '+r:(await(0,y.recipeCards)().signOff(a.id,{name:C(n),role:'head-chef'}),`Done: ${a.dish} signed off.`)}}]},1521,[943,1098,820,843,1117,1096,1111,968,858,816,996,942,944,1008,876,1065,867,847,845]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1522,[820,858,816,996,876,1001,1012,1013,973,972,1006,839,1032,1033,1034,1002,1065,867,1074,993,854,1523,1521]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),m=_r(_d[14]),f=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,j='Always check the signed-off recipe card and tell the kitchen about any allergy.';function H(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const Y=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function B(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,f.closedAreasAt)(f.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,m.nextFreeSentence)((0,m.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(H(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(B).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=Y(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+j}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+j}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),m=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),f=r.orders.filter(e=>e.restaurantId===t.rid),g=f.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,f,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+m+' covers booked so far.'}},{id:'supplier_list',title:'Add to a supplier shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft supplier list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1523,[820,938,1098,843,1137,1254,858,816,996,1001,956,846,845,1074,1075,993,1002,851,1524,1525]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return p}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[1]),d=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},p=(0,n.create)()((0,d.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,n,d,o,p)=>{const f=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===n&&'draft'===e.status);if(f){const t={...f,lines:[...f.lines,...d]};return e(e=>({drafts:e.drafts.map(e=>e.id===f.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:n,title:'Supplier shopping list',lines:d,by:o,app:p})},decide:(t,s,n)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:n,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,d.createJSONStorage)(()=>s.default)}))},1524,[824,831,834]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1525,[824,831,834]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1526,[816,876,956,851,1523,1015,1069]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,thirty:30},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1527,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"The voice assistant is on The Anchorage\u2019s Display only. Staff hold the gold button at the top right, say what they need and let go. Replies are shown in text. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,l.useDrafts)(e=>e.drafts),u=(0,l.useDrafts)(e=>e.decide),c=(0,r.useVoiceNav)(e=>e.go),[v,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:l.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The Assistant saves bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!v,onClose:()=>y(null),title:'approved'===v?.status?'Approve this draft?':'Dismiss this draft?',children:v?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:v.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===v.status?`This marks it approved${j[v.d.kind]?` and opens ${j[v.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===v.status?'success':'danger',label:'approved'===v.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(v.d.id,v.status,o.replace(' (example)',''));const e=j[v.d.kind];y(null),'approved'===v.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const j={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1528,[17,362,85,777,804,1463,1524,1475,1525,1352,890,1529,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1529,[17,85,777,804,1530,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1530,[824,831,834]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1531,[17,779,85,777,845,1251,1532,1533,804,8]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1532,[845]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1533,[946,1532,1254]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_r(_d[5]),c=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),b=_r(_d[10]),y=_r(_d[11]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1534,[17,85,777,858,1006,1535,938,839,1536,1018,804,1055,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1535,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(n){const{rid:o,date:c,bookings:f,cashUps:p,fields:h,soldOut:v}=n,b=f.filter(t=>t.restaurantId===o&&t.date===c),k=p.find(t=>t.rid===o&&t.date===c&&t.confirmedAt),O=p.find(n=>n.rid===o&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),y=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,N=(0,s.coversOn)(f,o,c),w=null==y||N<=0?null:Math.round(y/N*100)/100,D=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&D.set(n,(D.get(n)??0)+(t.partySize||0))}let S=null;for(const[t,n]of D)(!S||n>S.n)&&(S={hour:t,n:n});return{date:c,spendPerHead:l(w),covers:N,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:l(y),tips:l(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:l(O?(0,t.grossOf)(O.vals)??(0,t.takings)(O.vals):null),busiestHour:S?`${String(S.hour).padStart(2,'0')}:00 \xb7 ${S.n} Covers`:'Not entered',soldOut:v.filter(Boolean),cashUp:u(k?.vals,h,!!k)}};var t=r(d[0]),n=r(d[1]),s=r(d[2]);const l=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,o=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?l(t):String(t);function u(t,s,u){const c=[];for(const f of s){if('paidOut'===f.key){c.push({label:'Paid out',value:u?(0,n.paidOutDetail)(t):'Not entered'});const s=u?(0,n.expectedCashInDrawer)(t):null;c.push({label:'Expected cash in the drawer',value:null==s?'Not entered':l(s)});continue}c.push({label:f.label,value:u&&t?o(t[f.key],f.kind):'Not entered'})}if(u&&t&&!s.some(t=>'paidOut'===t.key)){c.push({label:'Paid out',value:(0,n.paidOutDetail)(t)});const s=(0,n.expectedCashInDrawer)(t);null!=s&&c.push({label:'Expected cash in the drawer',value:l(s)})}return c}},1536,[839,1007,1457]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1537,[812,17,85,777,1538,1019,804,1539,1055,8]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1538,[824,831,834]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1539,[1018,1019,935,892,946]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1540,[17,264,219,85,777,812,804,946,1418,1182,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1541,[219]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1543,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1544,[17,266,347,219,385,278,85,409,19,780,812,779,777,1220,1382,1085,1467,1084,1082,1222,1235,938,876,1030,1475,880,946,804,1327,1545,1055,1485,1407,1155,1469,1471,1460,1446,1473,1541,1543,1551,1552,1553,1556,1559,8]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.micAvailable=async function(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}},_e.NoShows=$,_e.CarApp=function(){(0,M.useCarViewport)();const{width:e,height:o}=(0,d.default)(),n=Math.max(320,E(e)),{role:c,today:u,now:h}=(0,w.useCtx)(3e4),[f,p]=(0,t.useState)(o),x=n,[y,I]=(0,t.useState)(null),[D,R]=(0,t.useState)(!1),[H,$]=(0,t.useState)(!1),[_,V]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==c&&T.useOwner.getState().setPreviewRole('owner')},[c]);const A=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,A);const G=(0,t.useCallback)(()=>R(!1),[]);(0,j.useBackLayer)(D,G);const Y=e=>{R(!1),I({btn:e,page:e.pages[0].id})},F=(0,t.useCallback)((e,t)=>{const o=e=>B.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:o('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:o('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??B.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=o(t);return I(o=>({btn:e??o?.btn??B.CAR_BUTTONS[0],page:t}))}I(null)},[]),X=x,q=y?y.btn.label:'';return(0,P.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-f)>1&&p(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:n,maxWidth:'100%',overflow:'hidden'},children:[(0,P.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,P.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,P.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,P.jsx)(W.ParkedOnly,{small:n<1400}),(0,P.jsx)(z,{open:D,onPress:()=>R(!0)})]}),subHeader:(0,P.jsx)(L,{onRota:()=>Y(B.CAR_BUTTONS[0]),onAccount:()=>$(!0)})}),y?(0,P.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:X,zIndex:40,backgroundColor:S.colours.bg},children:[(0,P.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${q}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||A()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,P.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,P.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,P.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,P.jsx)(z,{testID:"car-menu-button-page",open:D,onPress:()=>R(!0)})})]}),y.btn.pages.length>1?(0,P.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,P.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?O:'transparent',alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,P.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(0,P.jsx)(U,{id:y.page,go:F},y.page)})]}):null]}),(0,P.jsx)(N,{visible:D,onClose:G,onPick:Y,current:y?.btn.id,W:n,H:f}),H?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>$(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,P.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,P.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,P.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{$(!1),V(!0)},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>$(!1),style:{minHeight:56}})]}):null,_?(0,P.jsxs)(C.Sheet,{visible:!0,onClose:()=>V(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,P.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,P.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{V(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,P.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>V(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),d=e(r(_d[7])),c=r(_d[8]),u=e(c),h=r(_d[9]),b=r(_d[10]),f=r(_d[11]);r(_d[12]);var p=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),B=r(_d[26]),R=r(_d[27]),W=r(_d[28]),H=r(_d[29]),M=r(_d[30]),P=r(_d[31]);const O='rgba(201,162,74,0.14)';function L({onRota:e,onAccount:o}){const n=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[d,c]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>c(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=n.filter(e=>e.in&&!e.out&&d-new Date(e.in).getTime()<72e6&&d>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,P.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,P.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,P.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:o,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,P.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,P.jsx)(H.CarGameButton,{})]})}function $({go:e}){const{rid:t,now:o}=(0,w.useCtx)(3e4),n=(0,I.useBookings)(t),s=(0,D.ymd)(o),a=(0,D.ymd)(new Date(o.getTime()-24192e5)),d=n.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),c=n.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,P.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,P.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:d.length?`${d.length} no-show${1===d.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),c.length?(0,P.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),c.map(e=>(0,P.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,P.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,d.map(e=>(0,P.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,P.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,P.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,P.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function z({onPress:e,open:t,testID:o="car-menu-button"}){return(0,P.jsx)(s.default,{testID:o,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:B.MENU_BUTTON,height:B.MENU_BUTTON,borderRadius:B.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,P.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,P.jsx)(c.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function N({visible:e,onClose:a,onPick:d,current:c,W:u,H:b}){const[f,p]=(0,t.useState)(0),m=(0,B.menuSizes)(u,b),x=f?Math.floor((f-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new o.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),o.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:n.default.out(n.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,P.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,P.jsx)(o.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,P.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,P.jsxs)(o.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,P.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,P.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,P.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,P.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,P.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>p(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:B.CAR_BUTTONS.map(e=>{const t=c===e.id;return(0,P.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>d(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,P.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:O,alignItems:'center',justifyContent:'center'},children:(0,P.jsx)(R.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,P.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U({id:e,go:t}){if('@bookings'===e)return(0,P.jsx)(p.Bookings,{go:t});if('@chat'===e)return(0,P.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,P.jsx)($,{go:t});if('@orders'===e)return(0,P.jsx)(x.Orders,{});if('@forecast'===e)return(0,P.jsx)(y.Forecasts,{go:t});const o=(0,f.pageFor)(e);if(!o)return(0,P.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const n=o.C;return(0,P.jsx)(n,{go:t})}function E(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,o=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,o))}},1545,[17,266,347,219,385,278,85,409,780,779,1327,1446,1473,1407,1155,1471,1469,1055,1024,777,858,876,863,946,880,804,1546,1547,1548,1549,1550,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const t=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),l=Math.floor((t-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,l-28));return{panelW:t,colW:l,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return t}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'CookSafe log'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const t=s=>s.split('').join(' ')},1546,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1547,[17,780,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1548,[17,85,777,804,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1549,[17,385,1157,1158,816,805,777,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1550,[17,219]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=h,e.buttonsFor=function(s){return o.filter(t=>h(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),h=Math.floor(Math.max(88,(t-72-64-36)/i)),c=t>=1e3?15:13,k=Math.round(1.4*c),b=Math.max(48,Math.min(72,h-2*k-14,l-34));return{panelW:n,colW:l,per:h,circle:b,label:c,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return c}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}],last:[{id:'superpro-insights',label:'Insights',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function h(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const c=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1551,[1546]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1552,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1553,[17,385,85,409,812,777,1070,1030,1174,1118,1089,858,1006,876,1053,839,889,946,804,1407,1055,1446,1554,1543,1552,1555,8]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1554,[17,385,278,85,777,804,8]); +__d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1555,[17,85,780,777,804,1554,1552,8]); +__d(function(_g,_r,i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1556,[17,264,385,85,780,777,858,876,1557,961,1208,1453,804,1547,1055,1554,1558,1552,1555,1553,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1557,[831,834,824]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1558,[961]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1559,[17,85,777,804,1560,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1560,[]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:N,meId:H,me:Z}=(0,L.useCtx)(3e4);(0,x.useTipsPosted)(e,_);const q=(0,L.useSignedIn)();(0,m.useSoldOutLink)(!0,(q?.name??Z).replace(' (example)',''));const[J,Q]=(0,s.useState)({kind:'tab',tab:'home'}),[Y,ee]=(0,s.useState)(''),te=(0,s.useRef)(null);(0,s.useEffect)(()=>{(0,L.ensureAttendance)(_,N),(0,A.ensureChat)(N)},[_]),globalThis.__ccNow=N.getTime();const ae=(0,s.useCallback)((e,t=null)=>{if('more'===e&&t){const e=K[t];return void Q(e?{kind:'edit',id:e}:{kind:'page',id:t})}Q('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,s.useEffect)(()=>(C.useVoiceNav.setState({go:ae}),()=>C.useVoiceNav.setState({go:null})),[ae]),(0,s.useEffect)(()=>{T.PITCH&&(globalThis.__pitchGo=ae,globalThis.__deskGo=e=>Q(e))},[ae]),(0,v.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:q?.id??'',name:Z,onOpen:e=>'bookings'===e?ae('bookings'):'chat'===e?ae('chat'):ae('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!q});const se=(0,s.useMemo)(()=>[...F,...V].map(e=>e.s),[]);(0,s.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void te.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=se[Number(e.key)-1];return void(t&&(e.preventDefault(),Q(t)))}if('z'===t&&!G(e.target)){const t=(0,I.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!G(e.target)){const t=(0,I.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[se]);const ne=O.PAGES.filter(e=>'Retired'!==e.group&&(!e.can||e.can(f))&&!K[e.id]),oe=(0,s.useMemo)(()=>{const e=Y.trim().toLowerCase(),t={};return ne.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ne,Y]),re=F.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ie=p.CAN.forecasts(f)?V:V.filter(e=>'rota'===e.s.id),le='page'===J.kind?(0,O.pageFor)(J.id):void 0,de='tab'===J.kind?F.find(e=>U(e.s,J))?.label:'edit'===J.kind?V.find(e=>U(e.s,J))?.label:le?.title,ue='tab'===J.kind?F.find(e=>U(e.s,J))?.tip:'page'===J.kind?`${le?.sub??''}. Press ${(0,z.CMD)()}K to jump to any page.`:'',ce=({label:e,s:t,n:a})=>{const s=U(t,J);return(0,$.jsxs)(n.default,{accessibilityRole:"button",accessibilityState:{selected:s},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>Q(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:s?S.colours.goldTint:e?S.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:s?S.colours.gold:'transparent'}),children:[(0,$.jsx)(h.T,{size:14,weight:s?'semibold':'regular',colour:s?S.colours.gold:S.colours.text,style:{flex:1},numberOfLines:1,children:e}),a?(0,$.jsxs)(h.T,{size:11,colour:S.colours.muted,children:[(0,z.CMD)(),a]}):null]})},be=({t:e})=>(0,$.jsx)(h.T,{size:11,weight:"semibold",colour:S.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),ge='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,$.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:S.colours.bg},testID:"desktop-shell",children:[(0,$.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,$.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:S.colours.border},children:[(0,$.jsxs)(h.Row,{gap:10,children:[(0,$.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(u.VenueName,{name:c.name}),(0,$.jsx)(h.Row,{gap:6,children:(0,$.jsx)(l.AppBadge,{label:ge})})]})]}),(0,$.jsx)(u.PoweredBy,{}),(0,$.jsx)(a.TextInput,{ref:te,testID:"side-filter",value:Y,onChangeText:ee,placeholder:`Find a page (${(0,z.CMD)()}K)`,placeholderTextColor:S.colours.muted,style:[h.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,$.jsxs)(o.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[Y?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{t:"Run the day"}),re.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:t+1},e.label)),(0,$.jsx)(be,{t:"Drag-and-drop editors"}),ie.map((e,t)=>(0,$.jsx)(ce,{label:e.label,s:e.s,n:re.length+t+1},e.label))]}),Object.entries(oe).map(([e,t])=>(0,$.jsxs)(r.default,{children:[(0,$.jsx)(be,{t:e}),t.map(e=>(0,$.jsx)(ce,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,$.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,$.jsx)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:S.colours.border},children:(0,$.jsxs)(r.default,{style:{flex:1},children:[(0,$.jsx)(r.default,{testID:"desk-title",children:(0,$.jsx)(h.T,{size:24,weight:"bold",children:de??''})}),(0,$.jsxs)(h.Muted,{size:12,children:[q?`Signed in as ${q.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]})}),(0,$.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[ue?(0,$.jsx)(W.Tip,{children:ue}):null,'edit'===J.kind?(0,$.jsx)(X,{id:J.id,rid:e,me:Z,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,$.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===J.kind&&'home'===J.tab?(0,$.jsx)(R.Dashboard,{go:ae}):null,'tab'===J.kind&&'orders'===J.tab?(0,$.jsx)(B.Orders,{}):null,'tab'===J.kind&&'bookings'===J.tab?(0,$.jsx)(D.Bookings,{}):null,'tab'===J.kind&&'forecast'===J.tab?(0,$.jsx)(M.Forecasts,{go:ae}):null,'tab'===J.kind&&'chat'===J.tab?(0,$.jsx)(A.Chat,{go:ae}):null,le?(0,$.jsx)(le.C,{go:ae}):'page'===J.kind?(0,$.jsx)(h.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,$.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,$.jsx)(g.PrintHost,{rid:e}):null,'staff'!==f?(0,$.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Z,onOpen:e=>ae('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,$.jsx)(E.AssistantSheet,{}),(0,$.jsx)(P.OnboardingHost,{go:ae}),(0,$.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=e(_r(d[3])),o=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),g=_r(d[11]),h=_r(d[12]),f=_r(d[13]),p=_r(d[14]),m=_r(d[15]),x=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),S=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),P=_r(d[31]),B=_r(d[32]),O=_r(d[33]);_r(d[34]);var _=_r(d[35]),z=_r(d[36]),I=_r(d[37]),N=_r(d[38]),H=_r(d[39]),W=_r(d[40]),$=_r(d[41]);const F=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Tonight\u2019s Covers, bookings and orders at a glance. Use Find a page at the top of the sidebar to jump anywhere.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],V=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],K={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},U=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),G=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function X({id:e,rid:t,me:a,role:n,today:o,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,s.useState)(0),[g,p]=(0,s.useState)('');return'menu'===e?(0,$.jsx)(N.MenuEditor,{rid:t,me:a,role:n}):'rota'===e?(0,$.jsx)(H.RotaEditor,{today:o}):'brand'===e?(0,$.jsx)(_.BrandEditor,{rid:t}):(0,$.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,$.jsxs)(W.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,z.CMD)(),"Z undoes, then Save."]}),g?(0,$.jsx)(h.T,{size:13,colour:S.colours.goldLight,children:g}):null,(0,$.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:S.colours.border,borderRadius:12,overflow:'hidden'},children:(0,$.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1561,[813,812,17,385,278,85,19,1350,857,1355,1220,1382,777,996,876,938,1030,1467,1085,1084,1082,1475,1222,880,804,1485,1407,1155,1055,1420,1469,1460,1471,1446,1473,1562,1541,1564,1566,1568,1565,8]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1562,[17,278,85,1494,857,777,876,814,1447,804,1563,1564,1565,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1563,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1564,[17]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1565,[17,85,777,804,8]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1566,[812,17,85,777,860,816,938,940,941,845,867,1149,804,1563,1564,1565,1567,8]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1567,[876]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.RotaEditor=function({today:e}){const j=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[k,D]=(0,t.useState)((0,i.mondayOfDate)(e)),$=(0,h.useDateCalendar)(),[v,w]=(0,t.useState)(null),[B,O]=(0,t.useState)(''),P=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),I=x.map((e,t)=>(0,i.addDays)(k,t)),T=(e,t,o)=>{e.preventDefault(),w(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=j.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=k&&e.date<=I[6]),z=_.filter(e=>!e.published||e.changed).length;return(0,b.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,b.jsx)(f.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,b.jsxs)(s.Row,{gap:8,children:[(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>D((0,i.addDays)(k,-7))}),(0,b.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date(k+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>D((0,i.addDays)(k,7))}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",testID:"desk-rota-cal",label:"Calendar",accessibilityLabel:"Pick a date from the calendar",onPress:$.openCal}),(0,b.jsx)(h.AppDateCalendar,{visible:$.calOpen,today:e,day:k,idPrefix:"desk-rota-cal",onClose:$.closeCal,onDay:t=>D((0,i.mondayOfDate)(t??e))}),(0,b.jsx)(d.default,{style:{flex:1}}),B?(0,b.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:B}):null,(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"rota-undo"}),(0,b.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"rota-redo"}),(0,b.jsx)(s.Button,{small:!0,label:z?`Publish (${z})`:'Published',disabled:!z,onPress:()=>{P.record('published the week');const e=i.useOwner.getState().publishWeek(k);O(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,b.jsx)("div",{style:(0,f.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,b.jsxs)("div",{style:(0,f.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,b.jsx)("div",{style:(0,f.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),I.map((t,o)=>(0,b.jsxs)("div",{style:(0,f.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[x[o]," ",Number(t.slice(8))]},t)),j.map(e=>(0,b.jsxs)(o.default.Fragment,{children:[(0,b.jsxs)("div",{style:(0,f.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,b.jsx)("div",{style:(0,f.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,b.jsx)("div",{style:(0,f.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),I.map(t=>{const o=`${e.id}|${t}`,d=_.filter(o=>o.staffId===e.id&&o.date===t);return(0,b.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',w(o)},onDragLeave:()=>w(null),onDrop:o=>T(o,e.id,t),style:(0,f.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,b.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,f.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,b.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),f=r(_d[8]),h=r(_d[9]),p=r(_d[10]),b=r(_d[11]);const x=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],y=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1568,[17,85,777,876,1058,804,1563,1564,1565,1049,1567,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1569,[13,17,856,1570,8]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffApp=function(){return(0,je.jsx)(ee.StaffAppCtx.Provider,{value:!0,children:(0,je.jsx)(Ae,{})})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=_r(d[3]),r=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),C=_r(d[19]),S=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),W=_r(d[29]),L=_r(d[30]),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),_=e(_r(d[34])),D=e(_r(d[35])),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),ie=_r(d[53]),oe=_r(d[54]),re=_r(d[55]);_r(d[56]);var le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]),je=_r(d[71]);const we=ge.ROSTER.find(e=>'chef'===e.app)?.id,ve=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],Ce=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'cashup',label:'Cash up',icon:'cashup'},{id:'me',label:'Me',icon:'user'}],Se={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me',cashup:'Cash up'},Te={id:'staffchat',title:'Staff chat',sub:'Messages with the team on this venue'},Me=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: type in the cash up, including paid outs, or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Re=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Ae(){const{r:e,rid:r,me:n,meId:T,today:M,now:A}=(0,ee.useCtx)(3e4);(0,W.useReviewAlerts)(r),(0,he.useStaffTipsNotice)(r,M);const B=(0,ee.useSignedIn)(),fe=B?.ownerAccess&&'owner'!==B.role?'owner privileges':B?.managerAccess&&'staff'===B.role?'manager privileges':'',pe=(0,ee.useShiftManager)(),ge=(0,ke.useSync)(e=>e.perms),Ae=Re.filter(e=>'mgr-swaps'===e.id?ge.includes('rota.swap'):'mgr-times'!==e.id||(ge.includes('bookings.settings')||ge.includes('*')));(0,k.useSoldOutLink)(!0,n);(0,V.useOwner)(e=>e.staff);const Ie=(0,V.useOwner)(e=>e.staffCanViewSuppliers),[Oe,We]=(0,P.useState)('home'),[Le,ze]=(0,P.useState)(null),[Ee,He]=(0,P.useState)(!1),De=(0,P.useRef)(null);(0,P.useEffect)(()=>{(0,ee.ensureAttendance)(M,A),(0,G.ensureChat)(A)},[M]),globalThis.__ccNow=A.getTime();const Ne=(0,G.useChatUnread)().total,Fe=!0===(0,R.useCashAccess)(e=>e.mine),Ue=(0,P.useRef)({t:'home',s:null});Ue.current={t:Oe,s:Le};const Ve=(0,P.useRef)([]),$e=(0,P.useCallback)((e,s=null)=>{const t=Ue.current;t.t===e&&t.s===s||(Ve.current=[...Ve.current,{...t,y:Qe.leave()}].slice(-30),Qe.restore(0)),We(e),ze(s)},[]),Ge=(0,P.useCallback)(()=>{if((0,f.runBackLayer)())return!0;const e=Ue.current;let s=Ve.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=Ve.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Qe.leave(),We(t.t),ze(t.s),Qe.restore(t.y??0),!0},[]);(0,f.useWebBack)(Ge);const Ye=(0,f.useInnerBackShown)();(0,P.useEffect)(()=>{C.PITCH&&(globalThis.__pitchGo=$e,globalThis.__pitchClock={setClockServer:v.setClockServer,markClockSent:v.markClockSent,markClockUnsent:v.markClockUnsent})},[$e]),(0,P.useEffect)(()=>(0,w.startForegroundRefresh)(),[]),(0,Q.useShiftReminders)({rid:r,staffId:T,name:n,onStartBreak:()=>$e('clock')}),(0,J.useScheduledNotices)({rid:r,staffId:B?.id??'',name:n,onOpen:e=>{'orderlists'===e&&$e('me','orderlists'),'chat'===e&&(Fe?$e('me','staffchat'):$e('chat'))}}),(0,K.useOffRotaPrompt)({rid:r,staffId:B?.id??''});const Qe=(0,h.useScrollMemory)(De),Je=(0,P.useCallback)((e,s=null)=>'chat'===e||'staffchat'===s||'chat'===s?Fe?$e('me','staffchat'):$e('chat'):'cashup'===e?$e('cashup'):'clock'===s?$e('clock'):'rota'===s?$e('rota'):s&&Me.some(e=>e.id===s)?$e('me',s):'blocks'===s&&pe?$e('me','mgr-blocks'):void $e('home'===e?'home':'me'),[$e,pe,Fe]);(0,P.useEffect)(()=>{const e=z.default.addEventListener('hardwareBackPress',Ge);return()=>e.remove()},[Ge]);const Ke=Fe?[Te,...Me]:Me,qe='me'===Oe&&Le?Ke.find(e=>e.id===Le)??(pe?Ae.find(e=>e.id===Le):void 0):void 0,Xe=(0,Z.useOrderLists)(e=>e.settings[r]?.allowStaff??!0),Ze=Ke.filter(e=>('suppliers'!==e.id||Ie)&&('orderlists'!==e.id||Xe||B&&'staff'!==B.role)),es=Fe?Ce:ve,ss='cashup'===Oe||'cashup'===qe?.id?'cashup':Oe;(0,P.useEffect)(()=>{V.useOwner.getState().staffAs&&V.useOwner.setState({staffAs:void 0})},[]),(0,P.useEffect)(()=>{Fe&&'chat'===Oe&&$e('me','staffchat')},[Fe,Oe,$e]);(0,D.default)().width;return(0,je.jsxs)(N.SafeAreaView,{style:{flex:1,backgroundColor:$.colours.bg},edges:['top','left','right','bottom'],children:[(0,je.jsxs)(_.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:$.colours.border,gap:6},children:[(0,je.jsx)(_.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'100%'},children:(0,je.jsx)(E.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,o.privateClockVenue)(r)?`Signed in as ${n}`:'Signed in as'}${fe?`, ${fe}`:''}`,onPress:()=>He(!0),hitSlop:6,style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,je.jsxs)(F.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,je.jsx)(ye.StaffAvatar,{id:T,size:24,ring:!1}),(0,je.jsxs)(_.default,{style:{flexShrink:1},children:[(0,je.jsxs)(F.T,{size:13,weight:"semibold",colour:$.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),B?'':' (preview)'," \u25be"]}),fe?(0,je.jsx)(F.Muted,{center:!1,size:10,numberOfLines:1,children:fe}):null]})]})})}),(0,je.jsx)(U.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,je.jsxs)(H.default,{ref:De,...Qe.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:['home'===Oe?(0,je.jsx)(u.AlertsBanner,{}):null,'home'===Oe?(0,je.jsx)(c.WhosOnShift,{}):null,(0,je.jsx)(f.BackTitleRow,{back:!('home'===Oe&&!Le||Ye),onBack:Ge,title:qe?qe.title:Se[Oe]}),'home'===Oe&&pe?(0,je.jsx)(ie.ManagerFeaturesNote,{}):null,'home'===Oe&&B&&'staff'!==B.role&&!pe&&'undefined'!=typeof window?(0,je.jsxs)(_.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:$.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"You have manager access"}),(0,je.jsx)(F.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,je.jsx)(E.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:$.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,je.jsx)(F.T,{size:14,colour:$.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Oe&&B?(0,je.jsx)(S.MyTasksToday,{rid:r,staffId:B.id,name:B.name,onShift:(0,Q.shiftNow)(B.id,A.getTime()).on}):null,'home'===Oe?(0,je.jsx)(Be,{go:Je}):null,'clock'===Oe?(0,je.jsx)(ue.ClockInOut,{}):null,'rota'===Oe?(0,je.jsx)(ue.Rota,{}):null,'chat'===Oe||'staffchat'===qe?.id?(0,je.jsx)(G.Chat,{go:Je}):null,'cashup'===Oe?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'me'!==Oe||qe?null:(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.border,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ze.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),pe?(0,je.jsxs)(_.default,{testID:"manager-features",style:{gap:6},children:[(0,je.jsx)(F.T,{weight:"semibold",colour:$.colours.gold,children:"Manager features"}),(0,je.jsx)(_.default,{style:{borderRadius:14,borderWidth:1,borderColor:$.colours.gold,backgroundColor:$.colours.surface,overflow:'hidden'},children:Ae.map((e,s)=>(0,je.jsx)(E.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>$e('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:$.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,je.jsxs)(F.Row,{style:{justifyContent:'space-between'},children:[(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"medium",children:e.title}),(0,je.jsx)(F.Muted,{children:e.sub})]}),(0,je.jsx)(F.T,{colour:$.colours.muted,children:"\u203a"})]})},e.id))}),(0,je.jsx)(ie.ManagerFeaturesAbout,{})]}):null,Ie?null:(0,je.jsx)(F.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,je.jsxs)(F.Muted,{center:!0,children:["Staff app \xb7 ",j.APP_VERSION," \xb7 ",'live'===ke.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),pe&&qe?.id.startsWith('mgr-')?(0,je.jsxs)(ee.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===qe.id?(0,je.jsx)(s.TablePlan,{}):null,'mgr-times'===qe.id?(0,je.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===qe.id?(0,je.jsx)(Y.Bookings,{}):null,'mgr-clear'===qe.id?(0,je.jsx)(ie.TablesToClear,{rid:r}):null,'mgr-blocks'===qe.id?(0,je.jsx)(se.BlocksPage,{}):null,'mgr-allergy'===qe.id?(0,je.jsx)(te.AllergenSignOffLog,{}):null,'mgr-stock'===qe.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(ae.TrackedStockPage,{}),(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)','')})]}):null,'mgr-clock'===qe.id?(0,je.jsx)(ie.ClockOverview,{today:M,now:A}):null,'mgr-swaps'===qe.id?(0,je.jsx)(ie.SwapApprovals,{today:M,me:n}):null]}):null,'loyalty'===qe?.id?(0,je.jsx)(p.StaffLoyalty,{venue:e.name,canWrite:pe}):null,'guests'===qe?.id?(0,je.jsx)(b.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===qe?.id?(0,je.jsx)(Y.Bookings,{}):null,'giftcards'===qe?.id?(0,je.jsx)(y.GiftCardsPage,{me:n.replace(' (example)',''),canWrite:pe}):null,'tableorders'===qe?.id?(0,je.jsx)(l.StaffTableOrders,{rid:r,me:n.replace(' (example)',''),canWrite:pe}):null,'soldout'===qe?.id?(0,je.jsx)(x.SoldOutList,{rid:r,by:n.replace(' (example)',''),canMark:pe}):null,'board'===qe?.id?(0,je.jsx)(L.QuestionBoard,{rid:r,today:M,manager:!1,by:""}):null,'recipecards'===qe?.id?(0,je.jsx)(I.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===qe?.id?(0,je.jsx)(xe.AvatarMaker,{meId:T,me:n}):null,'cashup'===qe?.id?(0,je.jsx)(Pe,{rid:r,today:M,meId:T,me:n}):null,'haccp'===qe?.id?(0,je.jsx)(be.HaccpLog,{mode:"staff",me:n,meId:T,now:A,rid:e.id}):null,'accidents'===qe?.id?(0,je.jsx)(me.AccidentBook,{app:"staff",me:n,meId:T,now:A,seeAll:!1}):null,'mypay'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ne.MyHoursPay,{staffId:T})]}):null,'mytips'===qe?.id?(0,je.jsx)(he.MyTips,{}):null,'reviews'===qe?.id?(0,je.jsx)(O.ReviewsSection,{rid:r,mode:"read",venueName:e.name}):null,'timesheets'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(de.MyPeriods,{staffId:T}),(0,je.jsx)(ue.Timesheets,{})]}):null,'orderlists'===qe?.id?(0,je.jsx)(q.OrderListsScreen,{rid:r,today:M,editor:!!B&&'staff'!==B.role&&!pe,who:{id:T,name:n.replace(' (example)','')}}):null,'phone'===qe?.id?(0,je.jsx)(X.PhoneAlerts,{}):null,'suppliers'===qe?.id?Ie?(0,je.jsx)(ce.Suppliers,{}):(0,je.jsx)(F.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===qe?.id?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,o.privateClockVenue)(r)?(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(F.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,je.jsx)(F.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,je.jsxs)(je.Fragment,{children:[" ",(0,je.jsx)(F.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,je.jsxs)(F.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,je.jsx)(F.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,je.jsx)(le.BottomTabs,{background:(0,i.soutersSurface)('#0d0d0d'),active:ss,onPress:e=>$e(e),tabs:es.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&Ne||'me'===e.id&&Fe&&Ne?{text:String(Ne),bg:$.colours.red}:null}))}),(0,je.jsx)(F.Sheet,{visible:Ee,onClose:()=>He(!1),title:"Signed in as",children:B?(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsxs)(F.Row,{gap:10,children:[(0,je.jsx)(ye.StaffAvatar,{id:B.id,size:48}),(0,je.jsxs)(_.default,{style:{flex:1},children:[(0,je.jsx)(F.T,{weight:"semibold",children:B.name}),(0,je.jsx)(F.Muted,{children:(0,re.levelJob)(B.level??'Staff',B.job)})]})]}),(0,je.jsx)(F.Muted,{children:"Signed in with your personal link. This phone remembers you."}),pe?(0,je.jsx)(F.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===B.role||pe?null:(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),B.id===we?(0,je.jsx)(F.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,je.jsxs)(_.default,{style:{gap:8},children:[(0,je.jsx)(F.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,je.jsx)(oe.SignInWithLink,{})]})})]})}function Be({go:e}){const{rid:s,today:t}=(0,ee.useCtx)(3e4),i=(0,pe.useTravelDay)('staff',t);return(0,je.jsxs)(_.default,{style:{gap:10},children:[(0,je.jsx)(n.WhoBar,{}),(0,je.jsx)(pe.DayBar,{app:"staff",today:t}),i?null:(0,je.jsx)(r.CoversToday,{rid:s}),i?(0,je.jsx)(pe.DayView,{rid:s,day:i,today:t,app:"staff"}):(0,je.jsx)(fe.StaffHome,{go:e})]})}function Pe({rid:e,today:s,meId:t,me:i}){const o=(0,R.useCashAccess)(e=>e.mine),r=(0,R.useCashAccess)(e=>e.takings),l=(0,R.useCashAccess)(e=>e.tradingDate),n=(0,ke.useSync)(e=>e.perms),c=!1===r||null==r&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,B.tradingDay)();return(0,P.useEffect)(()=>{c&&(0,A.forgetPastTakings)(e,u)},[c,e,u]),!0!==o?(0,je.jsx)(M.NoCashUpAccess,{}):(0,je.jsx)(T.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:i.replace(' (example)','')}})}},1570,[1447,1571,813,958,1070,1503,1202,1203,1026,1023,1024,1504,1531,1506,1149,938,979,1572,976,880,1029,1030,1481,960,1006,961,17,1151,1231,1235,1197,356,385,278,85,409,19,777,857,876,804,1155,1407,1064,1082,1084,1079,1025,1008,1055,1497,1492,1513,1573,1415,966,219,1237,1176,1182,1445,1196,1193,1468,1179,878,1205,1206,884,776,946,8]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1571,[17,85,777,1055,946,8]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1572,[219,977]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1573,[843,17,85,777,876,996,863,1058,1056,946,1057,805,962,804,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1574,[13,17,856,8]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return K}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var o=r(_d[4]),n=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]),k=r(_d[27]);r(_d[28]);var I=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]),L=r(_d[38]);const M=r(_d[39]),D=r(_d[40]),U=r(_d[41]),q=r(_d[42]);function K(){const[e]=(0,o.useFonts)({Poppins_400Regular:M,Poppins_500Medium:D,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,C]=(0,d.useState)(A.useStore.persist.hasHydrated()),[F,B]=(0,d.useState)(x.useOwner.persist.hasHydrated()),V=s&&F;(0,d.useEffect)(()=>{const e=A.useStore.persist.onFinishHydration(()=>C(!0)),s=x.useOwner.persist.onFinishHydration(()=>B(!0));return A.useStore.persist.hasHydrated()&&C(!0),x.useOwner.persist.hasHydrated()&&B(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(A.useStore.persist.getOptions().name??'')&&(0,k.quietly)(()=>A.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(b.useFloor.persist.getOptions().name??'')&&(0,k.quietly)(()=>b.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(n.useBlocks.persist.getOptions().name??'')&&(0,k.quietly)(()=>n.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{V&&x.useOwner.getState().syncRoster()},[V]),(0,d.useEffect)(()=>{V&&(0,t.startAppSync)()},[V]);const N=e&&V,G=(0,E.useSignedOutGate)(),K=(0,u.usePathname)(),Q=N&&!(0,P.isAllowedPath)(K||'/');return(0,d.useEffect)(()=>{if(!Q)return;const e=setTimeout(()=>u.router.replace(P.ENTRY[P.APP_VARIANT]),0);return()=>clearTimeout(e)},[Q,K]),(0,d.useEffect)(()=>{N&&l.hideAsync().catch(()=>{})},[N]),N?(0,L.jsxs)(v.SafeAreaProvider,{children:[(0,L.jsx)(c.StatusBar,{style:"light"}),G?(0,L.jsx)(h.default,{style:{flex:1,backgroundColor:w.colours.bg}}):(0,L.jsx)(h.default,{style:{flex:1},children:(0,L.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:w.colours.bg}}})}),Q&&!G?(0,L.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:w.colours.bg}]}):null,Q||G||P.IS_CAR?null:(0,L.jsx)(H.VoiceHost,{}),G?null:(0,L.jsx)(I.SyncBadge,{}),Q||G||P.IS_CAR?null:(0,L.jsx)(R.PushPrompt,{}),P.IS_CAR?(0,L.jsx)(j.CarGate,{}):(0,L.jsx)(E.InviteGate,{}),(0,L.jsx)(O.BackToDisplay,{}),Q||G?null:(0,L.jsx)(T.SliderHost,{})]}):(0,L.jsxs)(h.default,{style:{flex:1,backgroundColor:w.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,L.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,L.jsx)(f.default,{color:w.colours.gold})]})}F.PITCH&&(globalThis.__pitch={useSaverCfg:G.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:P.APP_VARIANT,useStore:A.useStore,useOwner:x.useOwner,useFloor:b.useFloor,useBlocks:n.useBlocks,useSession:C.useSession,useCashUp:B.useCashUp,useCashAccess:V.useCashAccess,seedPitch:N.seedPitch},setTimeout(()=>{try{(0,N.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),C.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1575,[1440,946,778,1401,1576,993,13,1603,479,17,368,319,219,24,85,805,857,1063,856,1605,19,858,996,876,804,1415,966,987,1606,1607,1026,1608,1102,880,1006,960,1611,1372,8,1612,1613,1614,1615]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[1]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})});var o=r(d[2])},1576,[1577,1600,1602]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1577,[198,1578,1581,1595,1596,1597,1598,1599]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1578,[198,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1579,[1580]); +__d(function(g,r,i,a,m,e,d){},1580,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1581,[1582,198,1578,1595,1596]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var n=r(d[2]);Object.keys(n).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})},1582,[1583,1584,1594]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1583,[1584,1588,1593]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1584,[198,355,1585,1589,1590,1591,1592,1588,1593]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1585,[198,1586,322,263,1587,1588]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1586,[487]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1587,[198,322]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1588,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1589,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1590,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1591,[1589]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1592,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1593,[355,1587]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1594,[17,1584]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1595,[1582,198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1596,[1582,1595]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1597,[1578]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1598,[198,1578,1581,1579]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1599,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1600,[198,37,1601]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1601,[198]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1602,[17,1577]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0});var t=r(d[0]);Object.keys(t).forEach(function(n){'default'===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})},1603,[1604]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1604,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1605,[17,24,85,409,777,857,966,946,880,805,804,1546,1548,8]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1606,[951,868,867,946]); +__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1607,[813,779,812,17,975,1448,997,385,85,856,946,977,996,805,804,777,1339,935,880,8]); +__d(function(_g,_r,_i,_a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),E=_r(d[27]),M=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,O=16e3,V=31e3,B='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text isn\u2019t available just now. Tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the supplier list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the supplier list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,E.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Ee=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,M.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,M.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,M.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Me=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Ee);De.current=Ee;const Pe=(0,r.useRef)(Me);Pe.current=Me;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,M.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Oe='listening'===te,Ve='answer'===te&&(ae||de)||'working'===te||Oe,Be=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:B,tone:'warn'})):Pe.current())},'working'===te?O:V);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Ve?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Oe?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Be,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Oe?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Oe?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Be()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Be(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Oe?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Oe?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Oe?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,M.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,M.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,M.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1608,[805,779,812,17,368,266,347,363,219,385,278,409,85,1485,1351,880,780,1055,878,876,777,804,1519,891,1609,1517,1518,1475,1352,1530,890,1610,1527,8,260]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1609,[876,816,996]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1610,[831]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.seedPitch=function(){}},1611,[]); +__d(function(e,o,s,t,p,n,a){"use strict";p.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1612,[]); +__d(function(o,e,s,t,d,p,c){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1613,[]); +__d(function(o,e,s,t,d,p,f){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1614,[]); +__d(function(o,s,e,d,t,p,n){"use strict";t.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1615,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1616,[13,17,856,8]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1617,[1618]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(){const n=r(d[0]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),(function(t,n){for(var c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1618,[8,1619,574]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1619,[17,155]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1620,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1621,[8,482,17,253,634]); __r(484); __r(4); __r(0); \ No newline at end of file diff --git a/owner-desktop/index.html b/owner-desktop/index.html index 32007085e4363ff1386b7d194708fa43ef1499fe..105796c90e8a375ef00443e7d1a46bb0cc433d94 100644 --- a/owner-desktop/index.html +++ b/owner-desktop/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/owner.html b/owner-desktop/owner.html index 1cc1de79c2e09cf29f43519428ab834a78e0b53a..881d83935bba14cdae0b8ca70e289be251c003fc 100644 --- a/owner-desktop/owner.html +++ b/owner-desktop/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/sw.js b/owner-desktop/sw.js index e01fbc7dff41c97818f4bbab51f56f6f18c3c77f..bd9c06045510bd335648a82e127024248bba9ea4 100644 --- a/owner-desktop/sw.js +++ b/owner-desktop/sw.js @@ -1,7 +1,7 @@ // Anchorage owners desktop service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-desk-4a8a69ae3b"; +const V = "cc-desk-1471c63d5a"; const BASE = "/owner-desktop/"; -const PRECACHE = ["/owner-desktop/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-desktop/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-desktop/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-desktop/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-desktop/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-desktop/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-desktop/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-desktop/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-desktop/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-desktop/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-desktop/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-desktop/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-desktop/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-desktop/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-desktop/favicon.ico", "/owner-desktop/index.html", "/owner-desktop/_expo/static/js/web/bundle.js?v=4a8a69ae3bf17c5f414090cff40ffe627ca77ed482a8e92bbc58ea86a46fc65f"]; +const PRECACHE = ["/owner-desktop/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-desktop/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-desktop/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-desktop/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-desktop/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-desktop/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-desktop/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-desktop/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-desktop/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-desktop/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-desktop/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-desktop/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-desktop/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-desktop/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-desktop/favicon.ico", "/owner-desktop/index.html", "/owner-desktop/_expo/static/js/web/bundle.js?v=1471c63d5a719f5088f9daca82f00b692f4dcb98174e6a0c84dd3936226811bb"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/staff-app/_expo/static/js/web/bundle.js b/staff-app/_expo/static/js/web/bundle.js index 5c98ad8ad5dc229eec08b78af149b663ddf83419..6e0814893675399f46b6368aedad137699438421 100644 --- a/staff-app/_expo/static/js/web/bundle.js +++ b/staff-app/_expo/static/js/web/bundle.js @@ -1026,7 +1026,7 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},943,[820]); __d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANCHORAGE_STOCK",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(i.get(e),t)]))},_e.lastUndoable=function(e){const t=new Set(e.filter(e=>e.undoes).map(e=>e.undoes));return e.find(e=>'undo'!==e.reason&&'count'!==e.reason&&!t.has(e.id))},Object.defineProperty(_e,"fmtCount",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{key:'lobster',name:'Lobster',plural:'Lobsters',unit:'half',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd9e',sort:1,active:!0},{key:'crab',name:'Crab',plural:'Crabs',unit:'whole',lowAt:4,supplierId:'os-kittyfisher',icon:'\ud83e\udd80',sort:2,active:!0}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},944,[943]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},945,[856,17,85,946,880,804,777,8]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),i.rotaReconcile=Tt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(he.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(he.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=ya,i.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),i.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return va}}),i.claimInvite=Ka,i.makeChromeHandover=async function(){const e=Ee.getState();if(he.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.displayKitchenUnlock=async function(e){if(he.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.claimDisplayKitchen=async function(e){if(he.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},i.displayAssignKitchenRole=async function(e,t){if(he.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const i=n?.error;return'not_display'===i||'not_kitchen'===i||'not_kitchen_role'===i||'missing'===i?{ok:!1,error:i}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},i.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},i.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(he.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(he.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(he.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(he.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(he.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},i.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},i.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==i&&'unknown'!==i||await qa(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},i.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},i.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},i.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},i.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},i.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},i.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=La,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ba}}),i.mendSession=Wa,i.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,h.useGpCalc,ie.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),i.serverOrder=ss,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return ns}}),i.nudgeGuestSync=function(){is?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return rs}}),i.stockSaveBlocker=os,i.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=ds,i.saveStockEventsNow=us,i.bookingSaveBlocker=ls,i.resendUnsavedBookings=gs,i.saveBookingsNow=ms,i.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=ws,i.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),i=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=ks,i.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',i=vs().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=Os,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const i=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),h=t(r[10]),y=t(r[11]),S=t(r[12]),w=t(r[13]),v=t(r[14]),k=t(r[15]),b=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),T=t(r[24]),E=t(r[25]),N=t(r[26]),P=t(r[27]),K=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),j=t(r[32]),L=t(r[33]),B=t(r[34]),$=t(r[35]),F=t(r[36]),H=t(r[37]),W=t(r[38]),Q=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),Z=t(r[43]),z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=t(r[61]),me=t(r[62]),_e=t(r[63]),he=t(r[64]),ye=t(r[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(ye),we=t(r[66]),ve=t(r[67]),ke=t(r[68]),be=t(r[69]),Ie=t(r[70]),Re=t(r[71]),Oe=t(r[72]),Ae=t(r[73]),Ce=t(r[74]),De=t(r[75]),Ue=t(r[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function it(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function rt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,Ce.cardToRow)(s,a);return{...i,...r,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(r.map(e=>e.id));return i.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>ie.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ie.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ie.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,ht=!1;const yt=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:ht}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&yt.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:yt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>yt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:yt.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',i=Wt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,be.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=yt.get(e),i='*'===t?'*':Ht(t);if(n&&i)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?yt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ce.useOwner.getState().chatMarkRead(t,i)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ia(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ra(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,i),kind:'person',staffRef:i,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ha(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ya(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||he.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(he.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(he.PITCH)return(0,ye.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||he.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}i=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const i=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;yt.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>yt.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:yt.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),it(a),rt(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&i.push(Ps(a)),n&&(i.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ha('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&i.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>yt.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:yt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:yt.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ha('hr_questions')&&(i.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ha('temp_readings')&&(i.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ha('cooksafe_records')&&(i.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ha('sold_out_items')?(i.push(ma(a,await ha('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ha('sold_out_links')?(i.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(i.push(Zt(a)),n&&i.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ha('staff','nickname'),ht=await ha('staff','display_clock');const[e,t,s,n]=await Promise.all([ha('scheduled_notifications'),ha('order_lists'),ha('venue_clock_area'),ha('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(i.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(i.push(da(a)),ya()),t&&i.push(ua(a),ca(a),la(a)),s&&i.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ha('day_tips')){i.push(ia(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ha('tips_pot_events')&&i.push(ra(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(i.push(sa(a)),Ga.add('sales_reports')),t(r[78])(r[77],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Et(),Nt()),await ha('scheduled_notifications')&&i.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,y.costsAllowedFor)(e)};n&&u()&&await ha('ingredient_prices')&&(i.push((0,h.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ha('card_costs')&&(i.push((0,h.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ha('kitchen_deliveries')&&(i.push((0,h.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ha('kitchen_stock_counts')&&(i.push((0,h.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ha('specials_boards')&&(i.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=i.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),he.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),is=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let is=null;const rs={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let hs=null;const ys=(e=2500)=>{hs&&clearTimeout(hs),hs=setTimeout(()=>{hs=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&ys()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ys(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),i={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),r(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),r(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),r(ue.useSafety.getState(),i)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(i));const o=(0,U.stripHrSamples)(U.useHr.getState());r(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,h.stripGpSamples)(h.useGpCalc.getState());r(h.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',h.useGpCalc.getState()),h.useGpCalc.setState(d));const u=ie.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),ie.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return r(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:i})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=re.useAvatars.getState().photos[e];if(!t){a?.path&&re.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const i=await qs(s);i.startsWith('data:image/')&&re.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?yt.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=re.useAvatars.getState().photos[t];try{const n=Ms.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!re.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),i(n)),void(e&&re.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&i(n),re.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:re.useAvatars.getState().photos},s=re.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),re.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); +__d(function(e,t,a,s,n,r,i){"use strict";Object.defineProperty(r,'__esModule',{value:!0}),Object.defineProperty(r,"pointFromRow",{enumerable:!0,get:function(){return V.pointFromRow}}),Object.defineProperty(r,"pointToRow",{enumerable:!0,get:function(){return V.pointToRow}}),Object.defineProperty(r,"readingFromRow",{enumerable:!0,get:function(){return V.readingFromRow}}),Object.defineProperty(r,"readingToRow",{enumerable:!0,get:function(){return V.readingToRow}}),Object.defineProperty(r,"sameReading",{enumerable:!0,get:function(){return V.sameReading}}),Object.defineProperty(r,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(r,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(r,"changedFields",{enumerable:!0,get:function(){return A.changedFields}}),Object.defineProperty(r,"useSync",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(r,"can",{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(r,"isLive",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(r,"stockEventSaved",{enumerable:!0,get:function(){return at}}),Object.defineProperty(r,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ut}}),r.rotaReconcile=Tt,r.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ce.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ce.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ce.useOwner.getState().chatSeen(t,e)),Gt(e,t,a)},r.setTempManagerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setTempOwnerAccess=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Te().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ce.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},r.setManagerAccess=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Te().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const r=String(s??'');return ce.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...bt(r)}:t)})),{ok:!0,role:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.unlockCashUp=async function(e,t,a){if(ye.PITCH)return Se.unlockCashUp(e,t,a);const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:r}=await Te().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(r)return{ok:!1,message:r.message};const i=String(n);return'cashup'===e?pe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})):pe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:i}:e)})),{ok:!0,until:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.readCashAudit=async function(e){if(ye.PITCH)return Se.cashAudit(e);const t=Ee.getState().venueId;if(!t)return[];let a=Te().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,A.changedFields)(e.old_row,e.new_row)}))},r.readClockChanges=async function(e=30){if(ye.PITCH)return null;const t=Ee.getState().venueId;if(!t)return null;try{const{data:a,error:s}=await Te().rpc('owner_clock_changes',{p_venue:t,p_days:e});return s||!Array.isArray(a)?null:a}catch{return null}},r.readLoyaltyInsight=async function(){if(ye.PITCH)return null;const e=Ee.getState().venueId;if(!e)return null;try{const t=await Te().rpc('owner_loyalty_insight',{p_venue:e});if(!t.error&&t.data&&'object'==typeof t.data)return{raw:t.data,source:'server'};const a=await Te().rpc('loyalty_summary',{p_venue:e});return!a.error&&a.data&&'object'==typeof a.data?{raw:a.data,source:'summary'}:null}catch{return null}},r.setPushLive=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Te().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(va.setState({live:!!a,known:!0}),{ok:!0})},r.readPushLive=ha,r.readAccessLog=async function(){const e=Ee.getState().venueId;if(!e)return[];try{const{data:t}=await Te().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},r.readSyncHeartbeats=async function(){const e=Ee.getState().venueId;if(!e)return[];const{data:t,error:a}=await Te().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(r,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return Sa}}),r.uploadOrderLogo=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:r}=await Te().storage.from(Sa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return r?{ok:!1,message:r.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.orderLogoUrl=async function(e){const t=wa.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Te().storage.from(Sa).createSignedUrl(e,3600);if(t?.signedUrl)return wa.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},r.removeOrderLogo=async function(e){try{await Te().storage.from(Sa).remove([e])}catch{}},Object.defineProperty(r,"usePushLive",{enumerable:!0,get:function(){return va}}),r.claimInvite=Ka,r.makeChromeHandover=async function(){const e=Ee.getState();if(ye.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Te().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Me});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},r.claimChromeHandover=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_chrome_handover',{p_code:e,p_app:Me});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.displayKitchenUnlock=async function(e){if(ye.PITCH)return{ok:!1,error:'not_set'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:t,error:a}=await Te().rpc('display_kitchen_unlock',{p_code:e});if(a)return{ok:!1,error:'offline'};const s=t;if(s&&s.ok&&'string'==typeof s.ticket)return{ok:!0,ticket:s.ticket};const n=s?.error;return'wrong'===n||'locked'===n||'not_display'===n||'not_set'===n?{ok:!1,error:n}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.claimDisplayKitchen=async function(e){if(ye.PITCH||!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Te().rpc('claim_display_kitchen',{p_ticket:e});if(a){const e=a.message.replace(/^.*?:\s*/,'');return/expired|already signed in|no longer active|belongs to the Display/i.test(a.message)?{status:'refused',message:e}:{status:'refused',message:'Could not open the Head Chef app. Go back to the Display and enter the code again.'}}const s=t?.[0];if(!s)return{status:'refused',message:'That unlock has expired. Go back to the Display and enter the code again.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),Be&&Ha(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},r.endDisplayKitchen=async function(){try{qe(),await Te().rpc('end_display_kitchen')}catch{}try{await L.kv.remove(Da)}catch{}},r.displayAssignKitchenRole=async function(e,t){if(ye.PITCH)return{ok:!1,error:'not_display'};if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'offline'};try{qe();const{data:a,error:s}=await Te().rpc('display_assign_kitchen_role',{p_shift:e,p_badge:t??null});if(s)return{ok:!1,error:'offline'};const n=a;if(n&&n.ok)return{ok:!0,badge:n.badge??void 0};const r=n?.error;return'not_display'===r||'not_kitchen'===r||'not_kitchen_role'===r||'missing'===r?{ok:!1,error:r}:{ok:!1,error:'offline'}}catch{return{ok:!1,error:'offline'}}},r.signedInHereAs=async function(e){qe();const t=await L.kv.get(Da,null);return!!t&&'staff'===t.kind&&t.staffRef===e},r.rememberedInviteHere=async function(e){return qe(),await L.kv.get(Ua,null)===e},r.kirkmichaelStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.wildingsStaffAppUrl=async function(){const e=Ee.getState();if(!ee.IS_WILDINGS||'staff'!==e.kind||e.venueId!==ee.VENUE_UUID||e.staffRef!==D.useSession.getState().meId)return null;qe();const t=await L.kv.get(Ua,null);return t?(0,D.appUrl)('staff',t):null},r.forgetSignInHere=async function(){qe(),await L.kv.remove(Da),await L.kv.remove(Ua),Ne({mode:'signin',perms:[]});try{await Fa()}catch{}},r.approveShiftSwap=async function(e,t,a){const s=Ee.getState().venueId;if(ye.PITCH||!s||'staff'!==Ee.getState().kind)return{ok:!0};if(!(0,le.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ba('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},r.claimInviteForSync=async function(e){const t=await Ka(e);return'ok'===t.status?t.id:null},r.reissueInvite=async function(e){if(ye.PITCH)return Se.reissueInvite(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Te().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,r=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===r||'chef'===r?r:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},r.currentStaffAppLinks=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('current_staff_app_links',{p_venue:t,p_staff_ref:e})},r.makeStaffAppLink=async function(e,t){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Ba('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},r.staffAppLinkHistory=async function(e){return Ba('staff_app_link_history',{p_venue:Ee.getState().venueId,p_staff_ref:e})},r.revokeStaffAppLink=async function(e){await Ba('revoke_staff_app_link',{p_venue:Ee.getState().venueId,p_link_id:e})},r.staffLinkPhones=async function(){if(ye.PITCH)return Se.linkPhones();const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return{};try{const t=await Ba('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},r.resetStaffLinkPhone=async function(e){if(ye.PITCH)return Se.resetPhone(e);const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ba('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},r.readInviteStatus=async function(){if(ye.PITCH)return Se.inviteStatus();const e=Ee.getState().venueId;if(!e)return{};const{data:t,error:a}=await Te().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},r.pairWithCode=async function(e){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:t,error:a}=await Te().rpc((0,p.claimPairingRpc)(),{p_code:e});if(a)throw a;const s=t?.[0];if(!s)return{ok:!1,error:'That code was not accepted. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await L.kv.set(Ca,n),Ha(),{ok:!0,venueName:s.venue_name}}catch(e){const t=String(e?.message??e);return/fetch|network/i.test(t)?{ok:!1,error:'No connection. Check the tablet\u2019s Wi-Fi and try again.'}:/rate|too many/i.test(t)?{ok:!1,error:'Too many tries from this network. Wait a little and try again.'}:{ok:!1,error:/valid|switched off/i.test(t)?t:`Couldn\u2019t pair: ${t}`}}},r.carPairStart=async function(){if(!(0,K.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Pa();const{data:e,error:t}=await Te().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await L.kv.set(Ma,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:xa(e)}}},r.carPairPoll=async function(e){try{qe();const t=e??await L.kv.get(Ma,null);if(!t)return'unknown';const{data:a,error:s}=await Te().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],r=String(n?.status??'unknown');if((0,X.carPairApproved)(n)){const e=(0,X.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await L.kv.get(Ca,null);await L.kv.set(Ca,e),await L.kv.remove(Da),D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||Ha()}return'revoked'!==r&&'unknown'!==r||await qa(),r}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},r.carSignOut=async function(){try{qe(),await Te().rpc('car_sign_out')}catch{}await qa(),await Fa();try{await Te().auth.signOut({scope:'local'})}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},r.carApprove=async function(e,t="Tesla"){const a=Ee.getState().venueId;if(!a||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ba('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:xa(e)}}},r.carList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.carRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:xa(e)}}},r.assistantApprove=async function(e){const t=Ee.getState().venueId;if(!t||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const a=(await Ba('assistant_pair_approve',{p_venue:t,p_code:e}))?.[0];return a?.id?{ok:!0}:{ok:!1,message:String(a?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},r.assistantRevoke=async function(e){const t=Ee.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ba('assistant_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:ja(e)}}},r.assistantProposalsList=async function(){const e=Ee.getState().venueId;if(!e)return[];return(await Ba('assistant_proposals_list',{p_venue:e})??[]).map(e=>({id:String(e.id),kind:String(e.kind??''),summary:String(e.summary??''),warning:e.warning?String(e.warning):void 0,status:String(e.status??''),needsDoubleConfirm:!0===e.needs_double_confirm,canDecide:!0===e.can_decide,expiresAt:e.expires_at?String(e.expires_at):void 0,createdAt:e.created_at?String(e.created_at):void 0,decidedByName:e.decided_by_name?String(e.decided_by_name):void 0,appliedStamp:e.applied_stamp?String(e.applied_stamp):void 0,error:e.error?String(e.error):void 0}))},r.assistantProposalDecide=async function(e,t,a=!1){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const n=(await Ba('assistant_proposal_decide',{p_venue:s,p_id:e,p_decision:t,p_double_confirm:a}))?.[0];return n?.id?{ok:!0}:{ok:!1,message:String(n?.error??n?.message??'That change could not be confirmed.')}}catch(e){return{ok:!1,message:ja(e)}}},r.unpairDisplay=async function(){await L.kv.remove(Ca),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},r.disconnectStaff=async function(){await L.kv.remove(Da),await L.kv.remove(Ua),await Fa();try{await Te().auth.signOut()}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'Disconnected. Open your personal invite link to connect again.'})},r.wipeThisDevice=async function(e={}){try{await Fa()}catch{}try{(0,K.isSupabaseConfigured)()&&await Te().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${ee.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!ee.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ne({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},r.guestSession=La,Object.defineProperty(r,"rpc",{enumerable:!0,get:function(){return Ba}}),r.mendSession=Wa,r.startAppSync=async function(e=ee.VENUE_RID){if(ee.IS_ISOLATED_VENUE&&e!==ee.VENUE_RID)return;if(Be)return;Be=!0,Qa=e,'customer'===Me&&'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(qe(),'customer'!==Me){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Me&&(0,w.isAnchorage)(e)?[z.useStore,ce.useOwner,de.useKitchen,ue.useSafety,ne.useCardStore,y.useGpCalc,re.useOrderSheets,S.useSpecials,U.useHr]:[z.useStore,ce.useOwner,de.useKitchen];if(await Promise.all(a.map(t)),'chef'===Me&&(0,w.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ne({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Ts(e)}catch{if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e))return void Ne({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,K.isSupabaseConfigured)())return void Ne({mode:'off'});H.mutationQueue.subscribe(()=>{const e=H.mutationQueue.waiting,t=e[0];Ne({pending:H.mutationQueue.pending.length,failed:H.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,$.describeWrite)(t)}: ${(0,$.plainReason)({...t.lastErr},'retry')}`:void 0})}),H.mutationQueue.onFailed(e=>Ne({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:H.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,$.describeWrite)(e),why:'conflict'===e.reason?(0,$.plainReason)({code:'conflict'},'refused'):(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Le.push((0,M.onConnectivity)(e=>Ne({mode:e?Ee.getState().venueId?'live':Ee.getState().mode:Ee.getState().venueId?'offline':Ee.getState().mode}))),await Va()},Object.defineProperty(r,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return za}}),r.serverOrder=ss,Object.defineProperty(r,"guestWords",{enumerable:!0,get:function(){return ns}}),r.nudgeGuestSync=function(){rs?.()},Object.defineProperty(r,"syncInternals",{enumerable:!0,get:function(){return is}}),r.stockSaveBlocker=os,r.stockEventStatus=function(e){if(at(e))return{state:'saved'};const t=H.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,$.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},r.resendUnsavedStockEvents=ds,r.saveStockEventsNow=us,r.bookingSaveBlocker=ls,r.resendUnsavedBookings=gs,r.saveBookingsNow=ms,r.waitForBookingSave=function(e,t=12e3){if(!Ke())return Promise.resolve({state:'local'});const a=ls();if(a)return Promise.resolve({state:'refused',why:a});const s=fs()[0]?.venueId??'',n=()=>cs.some(t=>H.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const r=[],i=e=>{s||(s=!0,r.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=W.useBookingSaves.getState().notSaved[e];if(t)return i({state:'refused',why:t.why});n()||i((0,M.isOnline)()?{state:'saved'}:{state:'waiting'})};r.push(H.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),r.push(H.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>i(n()||fs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||fs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},r.tempSaveBlocker=ws,r.tempLogState=function(){const e=vs()[0]?.venueId??'',t=vs().find(e=>'temp_readings'===e.spec.table),a=H.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!H.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(Q.useTempSaves.getState().notSaved),r=ue.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>r.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},r.saveTempNow=ks,r.waitForTempSave=function(e,t,a=1e4){if(!Ke()||!vs().length)return Promise.resolve({state:'local'});const s=ws(e);if(s)return Promise.resolve({state:'refused',why:s});const n=vs()[0]?.venueId??'',r=vs().find(t=>t.spec.table===e),i=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>Q.useTempSaves.getState().notSaved[(0,Q.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>H.mutationQueue.hasPending(e,n,t)||!!r?.unsavedKeys().includes(t))?Date.now()-i>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},r.goLive=Os,Object.defineProperty(r,"usePublicDayStore",{enumerable:!0,get:function(){return $s}}),r.publicDay=function(e,t){const a=`${e}|${t}`,s=Bs.get(a);if('customer'!==Me||!(0,K.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Bs.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ba('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],r=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:He(a.booking_time),partySize:Number(a.covers)||0,table:(a.table_ids??[]).join('+')||void 0,durationMins:a.duration_mins??void 0,status:'confirmed',allergies:[],createdAt:''}):r.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:He(a.from_time),to:He(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Bs.set(a,{at:Date.now(),v:{bookings:n,blocks:r},ok:!0}),$s.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Bs.get(a);e&&!e.ok&&Bs.delete(a)}));const n=Bs.get(a);return n?.ok?n.v:null},r.saveStaffBookingTimes=async function(e,t,a,s){const n=Ee.getState().venueId;if(!n||'staff'!==Ee.getState().kind)throw new Error('Connect to your venue first.');const r=await Ba('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});z.useStore.getState().updateRestaurant(e,{...r,id:e})},r.staffTakeawayMenu=async function(){const e=Ee.getState().venueId;if(!e||'staff'!==Ee.getState().kind)return null;return(await Ba('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},r.setStaffTakeawayDish=async function(e,t,a){const s=Ee.getState().venueId;if(!s||'staff'!==Ee.getState().kind)throw new Error('Connect to the venue first.');await Ba('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(i[0]),d=t(i[1]),u=t(i[2]),c=t(i[3]),l=t(i[4]),f=t(i[5]),p=t(i[6]),g=t(i[7]),m=t(i[8]),_=t(i[9]),y=t(i[10]),h=t(i[11]),S=t(i[12]),w=t(i[13]),v=t(i[14]),k=t(i[15]),b=t(i[16]),I=t(i[17]),R=t(i[18]),O=t(i[19]),A=t(i[20]),C=t(i[21]),D=t(i[22]),U=t(i[23]),T=t(i[24]),E=t(i[25]),N=t(i[26]),P=t(i[27]),K=t(i[28]),M=t(i[29]),x=t(i[30]),q=t(i[31]),j=t(i[32]),L=t(i[33]),B=t(i[34]),$=t(i[35]),F=t(i[36]),H=t(i[37]),W=t(i[38]),Q=t(i[39]),V=t(i[40]),G=t(i[41]),J=t(i[42]),Z=t(i[43]),z=t(i[44]),Y=t(i[45]),X=t(i[46]),ee=t(i[47]),te=t(i[48]),ae=t(i[49]),se=t(i[50]),ne=t(i[51]),re=t(i[52]),ie=t(i[53]),oe=t(i[54]),de=t(i[55]),ue=t(i[56]),ce=t(i[57]),le=t(i[58]),fe=t(i[59]),pe=t(i[60]),ge=t(i[61]),me=t(i[62]),_e=t(i[63]),ye=t(i[64]),he=t(i[65]),Se=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(he),we=t(i[66]),ve=t(i[67]),ke=t(i[68]),be=t(i[69]),Ie=t(i[70]),Re=t(i[71]),Oe=t(i[72]),Ae=t(i[73]),Ce=t(i[74]),De=t(i[75]),Ue=t(i[76]);const Te=()=>(0,P.getSupabase)();H.mutationQueue.setExecutor(B.executeMutation),(0,q.setClockServer)(()=>'staff'===Ee.getState().kind);const Ee=(0,N.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ne=e=>Ee.setState(e),Pe=e=>{const t=Ee.getState().perms;return t.includes('*')||t.includes(e)},Ke=()=>{const e=Ee.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ee.subscribe(()=>(0,Ae.setLiveData)(Ke()));let Me=Y.IS_CAR?'car':Y.APP_VARIANT,xe=!1;const qe=()=>{xe||((0,L.setSyncNamespace)(Me),xe=!0)};let je=[],Le=[],Be=!1;const $e=()=>(new Date).toISOString().slice(0,10),Fe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),He=e=>e?e.slice(0,5):'',We=e=>Array.isArray(e)?e.filter(e=>e&&'object'==typeof e&&'string'==typeof e.allergen&&['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'].includes(e.allergen)&&(!e.severity||['intolerance','allergy','coeliac','anaphylaxis'].includes(e.severity))):[],Qe=e=>JSON.parse(JSON.stringify(e));function Ve(e,t){const a=Fe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>z.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Qe(e);if(t)return{id:e.id,venue_id:a,walk_date:e.date,arrived_at:e.seatedAt??e.createdAt,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,r='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),i=n.externalSource??(r?'Wix':null),o=n.externalId??(r?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,guest_name:e.name||'Guest',phone:e.phone??null,email:e.email??null,booking_date:e.date,booking_time:e.time,duration_mins:e.durationMins&&e.durationMins>=15&&e.durationMins<=720?e.durationMins:null,covers:Math.max(1,Math.min(200,e.partySize)),table_ids:e.table?e.table.split('+').map(e=>e.trim()).filter(Boolean):[],dog:!!e.dog,allergies:We(e.allergies),allergy_ack_by:e.allergyAck?.by??null,allergy_ack_at:e.allergyAck?.at??null,notes:e.notes??'',tags:e.tags??[],occasion:e.occasion??null,status:e.status,source:e.source??'in-person',security:e.security??'none',deposit_paid:e.depositPaid??0,seated_at:e.seatedAt??null,finished_at:e.finishedAt??null,created_at:e.createdAt,doc:s,...i?{external_source:i}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}'saved-card'===s.security&&(s.security='none');const n=a;return'string'==typeof n.phone&&n.phone.trim()&&(s.phone=n.phone.trim()),'string'==typeof n.email&&n.email.trim()&&(s.email=n.email.trim()),s},apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{bookings:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Ge(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>z.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('created_at',t),inWindow:e=>e.createdAt>=t,toRow:(e,t)=>({id:e.id,venue_id:t,ref:e.ref,customer_id:(0,le.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Qe(e.lines??[]),allergies:We(e.allergies),notes:e.notes??null,slot_time:e.slotTime??null,ready_by:e.readyBy??null,subtotal:Math.round(e.subtotal??0),tip:Math.round(e.tip??0),total:Math.round(e.total??0),paid:Math.round(e.paid??0),status:e.status,channel:e.channel??null,confirmed_by:e.accepted?e.accepted.by:null,confirmed_at:e.accepted?e.accepted.at:null,created_at:e.createdAt,allergy_chain:Qe(e.allergyChain??{}),readiness:Qe(e.readiness??{}),allergy_ticks:Qe(e.allergyTicks??{}),handover_check:e.handoverCheck?Qe(e.handoverCheck):null,accepted:e.accepted?Qe(e.accepted):null,doc:Qe(e)}),fromRow:t=>t.doc&&'object'==typeof t.doc?{...t.doc,id:String(t.id),restaurantId:e,status:t.status??t.doc.status}:null,apply:(e,t)=>z.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{orders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function Je(e){const t=Fe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...te.useBlocks.getState().blocks,...te.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.to>e.from,writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e},filter:e=>e.gte('block_date',t),inWindow:e=>e.date>=t,toRow:(e,t)=>({id:e.id,venue_id:t,block_date:e.date,from_time:e.from,to_time:e.to,reason:e.reason??null,note:e.note??null,area_id:e.areaId??null,area_name:e.areaName??null,created_by:e.by,created_at:e.createdAt,doc:Qe(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,te.blockClock)(t.from_time)??a?.from,n=(0,te.blockClock)(t.to_time)??a?.to,r='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&r?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:r,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>te.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>!i.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>te.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Ze=null,ze='Main plan';function Ye(e){const t=e=>Qe({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(ae.useFloor.getState().plans[e]??(0,ae.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Pe('floor.manage')||Pe('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Ze??(0,Ce.uuidFrom)(`plan:${a}`),venue_id:a,name:ze||'Main plan',is_active:!0,...t(e),updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>(Ze=String(e.id),ze=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,De.withSeedBest)(e,t[0]):void 0;a&&ae.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Xe(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>se.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Pe('stock.manage'),matchKey:e=>({key:e}),toRow:(e,t)=>({venue_id:t,key:e.key,name:e.name,plural:e.plural,unit:e.unit,low_at:e.lowAt,supplier_id:e.supplierId?(0,le.isUuid)(e.supplierId)?e.supplierId:(0,Ce.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),fromRow:e=>{return{key:e.key,name:e.name,plural:e.plural,unit:e.unit,lowAt:Number(e.low_at),icon:e.icon??'\u2022',sort:e.sort??0,active:!1!==e.active,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),pt.get(t)??t)}:{}};var t},apply:(t,a)=>se.useShellStore.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.key,e])),i=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>r.get(e.key)??e),o=new Set(i.map(e=>e.key));return{items:{...s.items,[e]:[...i,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const et=new Set,tt=new Set;H.mutationQueue.onDone(e=>{'stock_events'===e.table&&tt.add(e.rowKey)});const at=e=>tt.has(e)||et.has(e),st=()=>Pe('*')||Pe('staff.manage')||Pe('recipes.edit')||Pe('recipes.signoff'),nt=()=>'guest'!==Ee.getState().kind&&('device'!==Ee.getState().kind||Pe('device.write'));function rt(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>se.useShellStore.getState().events.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.id)&&!!(se.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>{const e=Ee.getState().kind;return'guest'!==e&&'assistant'!==e&&('device'!==e||Pe('device.write'))},filter:e=>e.gte('at',t).order('at',{ascending:!1}),inWindow:e=>e.at>=t,toRow:(e,t)=>({id:e.id,venue_id:t,item:e.kind,delta:e.delta,reason:e.reason,undoes:e.undoes&&(0,le.isUuid)(e.undoes)&&(at(e.undoes)||H.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(et.add(String(t.id)),{id:String(t.id),rid:e,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:new Date(t.at).toISOString(),...t.undoes?{undoes:String(t.undoes)}:{}}),apply:(e,t)=>se.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{events:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>se.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function it(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(se.useShellStore.getState().server[e]?.counts??{}).map(([e,t])=>({item:e,quantity:t})),key:e=>e.item,rowKey:e=>String(e.item),syncable:()=>!1,writable:()=>!1,toRow:()=>({}),fromRow:e=>({item:String(e.item),quantity:Number(e.quantity)}),apply:(a,s)=>{t={...se.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;se.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...et]}}}))},afterRead:()=>{se.useShellStore.getState().server[e]||se.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...et]}}}))},subscribe:()=>()=>{}}}const ot=new Set;function dt(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=z.useStore.getState().menu;return ne.useCardStore.getState().cards.filter(t=>t.restaurantId===e).map(e=>({card:e,item:t.find(t=>t.id===e.menuItemId)}))},key:e=>e.card.id,rowKey:e=>String(e.id),syncable:t=>(0,le.isUuid)(t.card.id)&&!((0,w.isAnchorage)(e)&&(0,w.isDemoCard)(t.card))&&!(0,w.isPlaceholderCard)(t.card),writable:()=>Pe('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,w.isAnchorage)(e)&&(s={...s,signOff:(0,w.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,w.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,w.isAnchorage)(e)&&(0,w.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,Ce.photoPath)(a,s),t=ut(s.photo);t&&((0,ne.cachePhotoAs)(e,t),ct(e,t)),s={...s,photo:e}}const{row:r,extra:i}=(0,Ce.cardToRow)(s,a);return{...r,...i,doc:Qe({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,w.isPlaceholderCard)(a.card))return null;const s=t.signed_off_by&&t.signed_off_at?{by:t.signed_off_by,at:new Date(t.signed_off_at).toISOString()}:null;return{card:{...a.card,id:String(t.id),restaurantId:e,signOff:s&&a.card.signOff?a.card.signOff:s,...t.photo_url?{photo:t.photo_url}:{}},item:a.item?{...a.item,restaurantId:e,signOff:(0,w.isAnchorage)(e)&&(0,w.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Pe('recipes.edit')&&t.length){const e=new Set(t);ne.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);ne.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),r=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),i=t.cards.filter(e=>!a.has(e.id)&&(s.has(e.id)||!n.has(e.menuItemId))).map(e=>s.get(e.id)??e),o=new Set(i.map(e=>e.id));return r.length&&z.useStore.setState(e=>({menu:e.menu.map(e=>r.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...i,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...r]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&z.useStore.setState(e=>{const t=new Map(s.map(e=>[e.id,e])),a=e.menu.map(e=>t.get(e.id)??e),n=new Set(a.map(e=>e.id));return{menu:[...a,...s.filter(e=>!n.has(e.id))]}})},subscribe:e=>{const t=ne.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=z.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const ut=e=>(0,ne.readLocalPhoto)(e);async function ct(e,t){if(!ot.has(e)){ot.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){ot.delete(e),Ne({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const lt=new Map,ft=(0,N.create)(()=>({n:0}));(0,ne.setStoragePhotoResolver)(e=>{const t=lt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,K.isSupabaseConfigured)()&&'off'!==Ee.getState().mode?(t||(lt.set(e,{url:'',at:Date.now()}),Te().storage.from(Ce.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(lt.set(e,{url:t.signedUrl,at:Date.now()}),ft.setState(e=>({n:e.n+1})),ne.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const pt=new Map;const gt=(e,t)=>{const a=(0,le.isUuid)(t)?t:(0,Ce.uuidFrom)(`sup:${e}:${t}`);return pt.set(a,t),a};function mt(e){return{name:'order_sheets',table:'suppliers',list:()=>re.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,w.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:gt(t,e.id),venue_id:t,name:e.name||'Supplier',category:e.goods||null,contact:e.contact??null,phones:e.number?[e.number]:[],website:e.url||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,notes:e.notes||null,doc:{kind:'sheet',localId:e.id,sheet:Qe(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(pt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>re.useOrderSheets.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>r.get(e.id)??e),o=new Set(i.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...i,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>re.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,le.isUuid)(e)?e:(0,Ce.uuidFrom)(`sup:${Ee.getState().venueId}:${e}`)})}}let _t=!1,yt=!1;const ht=new Map,St=new Map,wt=new Map,vt=new Map,kt=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',bt=e=>'owner'===e?{role:'owner',level:'Owner'}:'manager'===e?{role:'manager',level:'Manager'}:'supervisor'===e?{role:'manager',level:'Supervisor'}:'head_chef'===e?{role:'staff',level:'Head Chef'}:{role:'staff',level:'Staff'},It=(e,t)=>({...e,managerAccess:t}),Rt=()=>({nickname:_t,display:yt}),Ot=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=It({role:e.role,level:e.level??bt(kt(e)).level},!0===e.managerAccess);return(0,F.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},Rt())};const At=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},Ct=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},Dt=e=>{const t=ce.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ut=2e3;function Tt(e,t){return t||!e.length||e.length>=Ut?null:e=>(0,le.isUuid)(e.id)}function Et(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Tt(t,Pe('rota.manage')):null,keepOnEmpty:()=>e&&!Pe('rota.manage'),list:()=>ce.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&ht.has(e.staffId)&&(Pe('rota.manage')||Dt(e.staffId)),writable:()=>Pe('rota.manage')||Pe('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(At());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:Ct(e.start),end_time:Ct(e.end),published:!!e.published,doc:Qe(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,r]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,r).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{shifts:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Nt(){const e=Fe(62),t=e=>Pe('rota.manage')||e.staffId===Ee.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ce.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ee.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=Fe(2)&&e.staffId===Ee.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Qe(e.breaks??[]),break_mins:e.breakMins??0,doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,v.privateAttendance)(ee.VENUE_RID,{...e.doc,id:String(e.id)});return'confirmed'===e.status?t.signOff={by:String(e.confirmed_by_name??t.signOff?.by??'Manager'),byId:t.signOff?.byId??'',at:e.confirmed_at?new Date(e.confirmed_at).toISOString():t.signOff?.at??''}:delete t.signOff,t},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{attendance:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Pt(){const e=Fe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&e.staffId===Ee.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ee.getState().kind,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ht.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,le.isUuid)(e.attendanceId)?e.attendanceId:null,kind:e.kind,suggested_in:e.suggestedIn??null,suggested_out:e.suggestedOut??null,note:(e.note??'').slice(0,300)||null,status:'open',doc:Qe({...e,status:'open'})}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),date:String(e.work_date).slice(0,10),attendanceId:e.attendance_id?String(e.attendance_id):t.attendanceId,kind:e.kind,suggestedIn:e.suggested_in?new Date(e.suggested_in).toISOString():void 0,suggestedOut:e.suggested_out?new Date(e.suggested_out).toISOString():void 0,note:e.note??'',at:t.at??new Date(e.created_at).toISOString(),status:e.status,resolvedBy:e.resolved_by_name??void 0,resolvedAt:e.resolved_at?new Date(e.resolved_at).toISOString():void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{timeRequests:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Kt(e){ce.leaveRemote.decide=t=>!(!Pe('rota.manage')||!(0,le.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(H.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Le.push(()=>{ce.leaveRemote.decide=null})}function Mt(e){ce.timesheetRemote.send=(t,a)=>{if(!Pe('rota.manage')||!(0,le.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return H.mutationQueue.enqueue({table:'time_requests',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_status:s.status,p_doc:Qe(s)}}),!0}const s=a;if('attendance_void'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return H.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:'attendance_override',rowKey:s.id,values:{p_id:s.id,p_venue:e,p_staff_ref:s.staffId,p_work_date:s.date,p_clock_in:s.in,p_clock_out:s.out??null,p_break_mins:s.breakMins??0,p_breaks:Qe(s.breaks??[]),p_reason:n,p_doc:Qe((0,v.privateAttendance)(ee.VENUE_RID,s))}}),!0},Le.push(()=>{ce.timesheetRemote.send=null})}function xt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>z.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',new Date(Date.now()-2592e6).toISOString()),inWindow:()=>!1,toRow:(e,t)=>{return{id:(a=e.id,(0,le.isUuid)(a)?a:(0,Ce.uuidFrom)(`outbox:${a}`)),local_id:e.id,venue_id:t,channel:e.channel,kind:e.kind,to_address:e.to||'',to_name:e.toName||null,subject:e.subject??null,body:e.body,html:e.html??null,ref_type:e.refType,ref_id:(0,le.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Qe(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>z.useStore.setState(t=>{const a=new Set(t.outbox.map(e=>e.id));return{outbox:[...e.filter(e=>!a.has(e.id)),...t.outbox].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,300)}}),subscribe:e=>z.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const qt=e=>z.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function jt(e,t){if(!Array.isArray(t))return;const a=t.filter(e=>e&&'string'==typeof e.id&&'string'==typeof e.date&&'string'==typeof e.title).map(t=>({...t,restaurantId:e,example:!1}));z.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Lt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=z.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Qe({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:ae.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:qt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Pe('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...$t??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...$t?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...$t?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Bt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Bt=t.feature_flags??{},$t=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Qe({restaurant:{...a,id:e},msgTemplates:t.settings?.ops?.msgTemplates??{},display:t.settings?.ops?.display??{},games:!1!==t.feature_flags?.games,...Array.isArray(t.settings?.app?.events)?{events:t.settings.app.events}:{}})},apply:t=>{const a=t[0];a&&(z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withVenueAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&ae.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&jt(e,a.events))},subscribe:e=>{const t=z.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=ae.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Bt=null,$t=null;const Ft=()=>new Date(Date.now()-2592e6).toISOString(),Ht=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ht.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Wt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>St.get(e));return 2===t.length&&t[0]&&t[1]?(0,be.dmId)(t[0],t[1]):null},Qt=()=>Ee.getState().perms.includes('*');function Vt(){const e=()=>Ee.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ce.useOwner.getState().chat.filter(e=>(0,le.isUuid)(e.id)).map(e=>Qe({id:e.id,ch:e.ch,from:e.from,text:e.text,photo:e.photo,at:e.at,removed:!!e.removed})),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>!!Ht(t.ch)&&(t.from===e()||Qt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('created_at',Ft()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=Ft(),toRow:(e,t)=>{const a=Ht(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ht.get(e.from)??null;return{id:e.id,venue_id:t,channel:a,from_staff:s,body:e.text??null,photo:e.photo??null,removed:e.removed,created_at:e.at}},fromRow:e=>{const t=Wt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?St.get(String(e.from_staff)):'system';return s?Qe({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ce.useOwner.setState(s=>{const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>r.has(e.id)?{...e,...r.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=i&&s.chatRead?.[i]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===i?[e.from]:i&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[i]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?St.get(String(t.from_staff)):'system',r=Wt(String(t.channel)),i=e();if(!r||!i||n===i||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ce.useOwner.getState();if((o.chatMuted[i]??[]).includes(r))return;if(!(0,be.inChannel)(r,o.staff.find(e=>e.id===i)))return;if((0,Ie.soundAllowed)())try{(0,Ie.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=r.startsWith('dm:')?'sent you a message':`in ${'all'===r?'Everyone':'foh'===r?'Front of house':'kitchen'===r?'Kitchen':'managers'===r?'Managers':r}`,c=String(t.body??t.text??'').slice(0,120);(0,I.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Gt(e,t,a){const s=Ee.getState();if(!ke.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ht.get(e),r='*'===t?'*':Ht(t);if(n&&r)try{await Te().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:r,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Jt(e){const t=Ee.getState().staffRef,a=t?ht.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Te().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const r={};for(const e of s){const t='*'===e.channel?'*':Wt(String(e.channel));t&&(r[t]=new Date(e.read_at).toISOString())}Object.keys(r).length&&ce.useOwner.getState().chatMarkRead(t,r)}catch{}}function Zt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=T.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Qe(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>T.useReminders.setState(s=>{const n=new Set(a),r={...s.rules},i=t.filter(e=>'break_rules'===e.kind);for(const t of i)r[e]={...(0,E.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};r[e]&&n.has(r[e].id)&&delete r[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:r,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function zt(e){const t=Fe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>T.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.reminderId)&&e.staffRef===Ee.getState().staffRef,writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>T.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{done:[...e.filter(e=>!i.has(e.id)),...r].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>T.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Yt(e,t,a,s=()=>!0){const n=new Set(a),r=new Map(t.map(e=>[e.id,e])),i=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&r.has(e.id)?r.get(e.id):e),o=new Set(i.map(e=>e.id));return[...i,...t.filter(e=>!o.has(e.id))]}const Xt=e=>null==e||''===e?null:Number(e),ea=e=>e.filter(e=>!e.startsWith('data:')),ta=()=>Pe('takings.view');function aa(e){const t=!ta();return{name:'cash_ups',table:'cash_ups',list:()=>pe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',Fe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>(0,C.cashUpToRow)(e,t),fromRow:t=>(0,C.cashUpFromRow)(t,e),apply:(t,a)=>pe.useCashUp.setState(s=>({cashUps:Yt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function sa(e){return{name:'sales_reports',table:'sales_reports',list:()=>pe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Pe('wages.manage')||(0,k.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Qe(e.vals),categories:e.categories,photos:ea(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>pe.useCashUp.setState(s=>({sales:Yt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function na(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=pe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,pe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Qe({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,pe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>pe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ra(e){return{name:'day_tips',table:'day_tips',list:()=>pe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',Fe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>pe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ia(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>pe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Xt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>pe.useCashUp.setState(s=>({pot:Yt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function oa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=pe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Pe('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>pe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>pe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function da(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>fe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Qe(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>fe.useNotifs.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>fe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ua(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ge.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,le.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Qe(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Qe(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ge.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...me.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const r=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Yt(s.lists,r,a,t=>t.rid===e)}}),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ca(e){const t=()=>Pe('venue.settings')||Pe('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ge.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,le.isUuid)(a.id)&&(0,le.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ge.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ee.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ee.getState().staffRef)||null,doc:Qe(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({items:Yt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function la(e){const t=Fe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ge.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('venue.settings')||Pe('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Qe(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ge.useOrderLists.setState(s=>({history:Yt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ge.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function fa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=_e.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Qe(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Pe('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&_e.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,v.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>_e.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function pa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=we.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,we.libraryRowId)(e),kind:'library',doc:Qe({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,r]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,we.personRowId)(e,r),kind:'person',staffRef:r,doc:Qe({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ce.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,ve.canEditTasks)(t,a)},writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>we.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,we.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ga(e){const t=Fe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>we.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ee.getState();return e.byRef===t.staffRef||Pe('staff.manage')},writable:()=>'staff'===Ee.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>we.useDailyTasks.setState(s=>({ticks:Yt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>we.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ma(e,t=!1){const a=Fe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>Re.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,Ce.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>Re.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>Re.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{Oe.autoSync.soldOutRead.add(e)}}}function _a(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>Oe.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:(0,Ce.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>Oe.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>Oe.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{Oe.autoSync.linksRead.add(e)}}}async function ya(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Te().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&L.kv.get(a,!1):(L.kv.set(a,!0),!0)}catch{return L.kv.get(a,!1)}}async function ha(){const e=Ee.getState().venueId;if(e)try{const{data:t}=await Te().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();va.setState({live:!!t?.push_live,known:!0})}catch{}}const Sa='order-list-logos';const wa=new Map;const va=(0,N.create)(()=>({live:!1,known:!1}));async function ka(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('reminders:ok',!1):(L.kv.set('reminders:ok',!0),!0)}catch{return L.kv.get('reminders:ok',!1)}}async function ba(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Te().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&L.kv.get('chat:ok',!1):(L.kv.set('chat:ok',!0),!0)}catch{return L.kv.get('chat:ok',!1)}}const Ia=(e,t)=>Qe({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),Ra='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function Oa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>U.useHr.getState().questions.filter(t=>t.venue===e&&(0,le.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>Ia(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);U.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),r=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!r.has(e.id))]}})},subscribe:e=>U.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function Aa(e,t){const a=(t,a,s)=>{H.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(U.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,r)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:r}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Te().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Te().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Te().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Te().from('hr_questions').select(Ra).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||U.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>Ia(e,t)))}catch{}}}),Le.push(()=>{Object.assign(U.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const Ca='pair:v1',Da='staff:v1',Ua='staff:rejoin:v1';async function Ta(e){const t=(0,p.claimInviteRpc)(),a={p_token:e,p_app:Me,p_device:(0,D.deviceId)()},s=await Te().rpc(t,{...a,p_phone:(0,D.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Te().rpc(t,a):s}async function Ea(){if('display'===Me||'customer'===Me||ye.PITCH)return'none';const e=await L.kv.get(Ua,null);if(!e)return'none';try{await Pa();const{data:t,error:a}=await Ta(e);if(a)return(0,O.inviteRefusal)(a.message)?(await L.kv.remove(Ua),await L.kv.remove(Da),'refused'):'offline';const s=t?.[0];return s?(await L.kv.set(Da,{kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name}),'ok'):(await L.kv.remove(Ua),'refused')}catch{return'offline'}}const Na=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Pa(){qe();const{data:e}=await Te().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Te().auth.signInAnonymously();if(!t)return;const a=429===t.status||/rate|too many/i.test(t.message);if(!a||e>=2){if(a)throw new Error('Too many people are connecting from this network right now. Wait a few minutes, or switch to mobile data, and open the link again.');throw t}Ne({message:'Lots of people are connecting at once. Trying again in a moment\u2026'}),await new Promise(t=>setTimeout(t,0===e?15e3:45e3))}}async function Ka(e){if(ye.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,K.isSupabaseConfigured)())return{status:'off'};try{await Pa();const{data:t,error:a}=await Ta(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,ee.venueKey)(`cc-pending-invite:${Me}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={kind:'staff',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,staffRef:s.external_ref,staffUuid:s.staff_id,role:s.role_key,displayName:s.display_name};return await L.kv.set(Da,n),await L.kv.set(Ua,e),Be&&Ha(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ne({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ma='car:request:v1',xa=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function qa(){await L.kv.remove(Ca),await L.kv.remove(Da),await L.kv.remove(Ma),D.useSession.getState().meId&&D.useSession.getState().signOut()}const ja=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check your signal and try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function La(){if(!(0,K.isSupabaseConfigured)())return!1;try{return await Pa(),!0}catch{return!1}}const Ba=async(e,t={})=>{if(ye.PITCH)return(0,he.pitchRpc)(e,t);const{data:a,error:s}=await Te().rpc(e,t);if(s)throw s;return a};let $a=null;async function Fa(){for(const e of Le)try{e()}catch{}Le=[],je.forEach(e=>e.stop()),je=[],$a&&(clearInterval($a),$a=null)}async function Ha(){await Fa(),await Va()}async function Wa(){if(!(0,K.isSupabaseConfigured)()||'customer'===Me||ye.PITCH)return!1;try{qe();const{data:e}=await Te().auth.getSession();if(e.session){const{error:e}=await Te().auth.refreshSession();if(!e)return!0}if('display'===Me)return!1;if(!await L.kv.get(Ua,null))return!1;if(e.session)try{await Te().auth.signOut({scope:'local'})}catch{}return'ok'===await Ea()&&(Ha(),!0)}catch{return!1}}(0,c.setSessionMender)(Wa);let Qa=ee.VENUE_RID;async function Va(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Qa;try{if(Ne({mode:'connecting'}),await H.mutationQueue.load(),'customer'===Me)return void await Xa(e);let t=await L.kv.get(Ca,null),a=await L.kv.get(Da,null);if(Y.IS_CAR&&!t&&a){const e=(0,X.migrateCarStaffIdentity)(a);e&&(t=e,await L.kv.set(Ca,t)),await L.kv.remove(Da),a=null,D.useSession.getState().meId&&D.useSession.getState().signOut()}if(ee.IS_ISOLATED_VENUE&&(t&&!(0,ee.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,ee.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ne({mode:'display'===Me?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Te().auth.getSession();if('display'!==Me&&!Y.IS_CAR&&a&&!s.session){const t=await Ea();if('offline'===t)return Ne({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Qa===e&&Ha()},6e4);'refused'===t&&a.staffRef&&D.useSession.getState().meId===a.staffRef&&D.useSession.getState().signOut(),a=await L.kv.get(Da,null),({data:s}=await Te().auth.getSession())}const n='display'===Me||Y.IS_CAR?t:a;if(!s.session||!n)return void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[]});let r=[];try{const e=(await Ba('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Me||Y.IS_CAR?await L.kv.remove(Ca):(await L.kv.remove(Da),await L.kv.remove(Ua)),'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId===n.staffRef&&D.useSession.getState().signOut(),void Ne({mode:'display'===Me||Y.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Me?'This display was unpaired by a manager.':Y.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});r=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&r.push('device.write')}catch(t){if(!(0,M.isOnline)()||/fetch|network/i.test(String(t?.message)))Ne({mode:'offline'});else if(Na(t)&&'display'!==Me){const{error:t}=await Te().auth.refreshSession();t&&'ok'===await Ea()&&setTimeout(()=>{Qa===e&&Ha()},500)}r=Ee.getState().perms,'device'===n.kind&&n.canWrite&&!r.includes('device.write')&&(r=[...r,'device.write'])}Ne({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:r}),!Y.IS_CAR&&'staff'===n.kind&&n.staffRef&&D.useSession.getState().meId!==n.staffRef&&(D.useSession.getState().signIn(n.staffRef),ce.useOwner.setState({staffAs:n.staffRef})),Y.IS_CAR&&(D.useSession.getState().meId&&D.useSession.getState().signOut(),ce.useOwner.setState({previewRole:'owner'})),await Ja(n.venueId,e,n.kind)}catch(e){Ne({mode:'local',lastError:String(e?.message??e)})}}const Ga=new Set(['venues','staff','bookings','walk_ins','blocks','table_plans','takeaway_orders','stock_items','stock_events','stock_counts','recipe_cards','suppliers','supplier_orders','rota_shifts','attendance','time_requests','game_scores','floor_live','chat_messages','venue_reminders','reminder_done']);async function Ja(e,a,s){if(!(0,ee.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||Y.IS_CAR&&'device'===s;await Os(a),Le.push(Ls(e));try{const{data:t}=await Te().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])wt.set(e.key,e.id),vt.set(e.id,e.key)}catch{}const r=[Lt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ce.useOwner.getState().staff.map(Ot),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Pe('staff.manage'),deletes:!1,revision:e=>(0,F.staffRevision)(e,Rt()),toRow:(e,t)=>(0,F.staffRow)(e,t,Rt(),e.managerAccess||e.ownerAccess?null:wt.get(kt(e))),fromRow:e=>{if(!e.external_ref)return null;ht.set(String(e.external_ref),String(e.id)),St.set(String(e.id),String(e.external_ref)),Ms.set(String(e.external_ref),e.avatar_path??null);const t=It(bt(vt.get(String(e.role_id))),!0===e.manager_access);return(0,F.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},Rt())},apply:e=>ce.useOwner.setState(t=>{const a=new Map(e.map(e=>[e.id,e])),s=t.staff.map(e=>a.has(e.id)?{...e,...a.get(e.id)}:e),n=new Set(s.map(e=>e.id));return{staff:[...s,...e.filter(e=>!n.has(e.id)).map(e=>({...e}))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{js()},onRemote:()=>{js()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ce.useOwner.getState(),t=oe.useSetup.getState().sites[Qa]?.staffGrade??{};return e.staff.filter(e=>ht.has(e.id)).map(a=>Qe({id:a.id,hourly:e.hourly[a.id]??null,salaried:!!a.salaried,noTax:!!a.noTax,grade:t[a.id]||void 0}))},key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ht.get(e.id),venue_id:t,hourly_rate:null==e.hourly?null:e.hourly/100,salaried:e.salaried,no_tax:e.noTax,pay_grade:e.grade??null}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?Qe({id:t,hourly:null==e.hourly_rate?null:Math.round(100*Number(e.hourly_rate)),salaried:!!e.salaried,noTax:!!e.no_tax,grade:e.pay_grade||void 0}):null},apply:e=>ce.useOwner.setState(t=>{const a={...t.hourly},s=new Map(e.map(e=>[e.id,e]));for(const t of e)null==t.hourly?delete a[t.id]:a[t.id]=t.hourly;if(e.length){const t=oe.useSetup.getState().sites[Qa],a={...t?.staffGrade??{}};let s=!1;for(const t of e)(a[t.id]||void 0)!==t.grade&&(s=!0,t.grade?a[t.id]=t.grade:delete a[t.id]);s&&oe.useSetup.getState().patch(Qa,{staffGrade:a})}return{hourly:a,staff:t.staff.map(e=>s.has(e.id)?{...e,salaried:s.get(e.id).salaried,noTax:s.get(e.id).noTax}:e)}}),subscribe:e=>{const t=ce.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=oe.useSetup.subscribe((t,a)=>{t.sites[Qa]?.staffGrade!==a.sites[Qa]?.staffGrade&&e()});return()=>{t(),a()}}},Ve(a,!1),Ve(a,!0),Je(a),Ye(a),Ge(a),Xe(a),rt(a),it(a),mt(a),{name:'supplier_directory',table:'suppliers',list:()=>ce.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,le.isUuid)(e.id),writable:()=>Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,name:e.name||'Supplier',category:e.category,contact:e.contact||null,phones:e.phones.filter(Boolean),email:e.email||null,website:e.website||null,account_ref:e.account||null,cutoff:e.cutoff||null,order_days:e.orderDays,delivery_days:e.deliveryDays,doc:{kind:'directory',localId:e.id,supplier:Qe(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{suppliers:[...r,...e.filter(e=>!i.has(e.id))]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ce.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId),writable:()=>Pe('suppliers.order')||Pe('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||$e(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Qe(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},dt(a),Ns(a)];Pe('wages.view')&&r.push(Ps(a)),n&&(r.push(Et(!0),Nt(),Pt(),xt(a)),Mt(e)),n&&await ya('staff_leave')&&(r.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ce.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,le.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ee.getState().staffRef&&'pending'===e.status||Pe('rota.manage')),writable:()=>'staff'===Ee.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Qe(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ce.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),r=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),i=new Set(r.map(e=>e.id));return{leave:[...e.filter(e=>!i.has(e.id)),...r]}}),subscribe:e=>ce.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Ga.add('staff_leave'),Kt(e));const o=n&&await ba();if(ke.useChatSync.setState({synced:o,checked:!0}),Le.push(()=>ke.useChatSync.setState({synced:!1})),o&&r.push(Vt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(be.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>St.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ht.has(e.id),writable:()=>Pe('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ht.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ht.get(e.id),include:e.include}),fromRow:e=>{const t=St.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>be.useKitchenExtra.setState(a=>{const s={...a.extra};return t.forEach(e=>{delete s[e]}),e.forEach(e=>{s[e.id]=e.include}),{extra:s}}),subscribe:e=>be.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await ya('hr_questions')&&(r.push(Oa(a)),Ga.add('hr_questions'),Aa(e,a)),'guest'!==s&&'customer'!==Me&&await ya('temp_readings')&&(r.push((0,V.tempUnitsSpec)(ue.useSafety,st),(0,V.tempReadingsSpec)(ue.useSafety,nt)),Ga.add('temp_units'),Ga.add('temp_readings')),'guest'!==s&&'customer'!==Me&&await ya('cooksafe_records')&&(r.push((0,G.cooksafeSpec)(ue.useSafety,J.useCookSafe,ue.isSeedAccident,nt)),Ga.add('cooksafe_records')),'guest'!==s&&await ya('sold_out_items')?(r.push(ma(a,await ya('sold_out_items','auto'))),Ga.add('sold_out_items')):Oe.autoSync.soldOutRead.add(a),'guest'!==s&&await ya('sold_out_links')?(r.push(_a(a)),Ga.add('sold_out_links')):Oe.autoSync.linksRead.add(a),T.useReminders.getState().ensure(a),'guest'!==s&&await ka()&&(r.push(Zt(a)),n&&r.push(zt(a))),fe.useNotifs.getState().ensure(a),ge.useOrderLists.getState().ensure(a),n){_t=await ya('staff','nickname'),yt=await ya('staff','display_clock');const[e,t,s,n]=await Promise.all([ya('scheduled_notifications'),ya('order_lists'),ya('venue_clock_area'),ya('daily_tasks')]);we.useDailyTasks.getState().ensure(a),n&&(r.push(pa(a),ga(a)),Ga.add('daily_tasks'),Ga.add('daily_task_ticks')),e&&(r.push(da(a)),ha()),t&&r.push(ua(a),ca(a),la(a)),s&&r.push(fa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Ga.add(n)}if('guest'!==s&&await ya('day_tips')){r.push(ra(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Ga.add(e);await ya('tips_pot_events')&&r.push(ia(a),oa(a)),n&&(ta()||(0,pe.forgetPastTakings)(a,(0,b.tradingDay)()),r.push(aa(a),na(a)),Ga.add('cash_ups'),ta()&&(r.push(sa(a)),Ga.add('sales_reports')),t(i[78])(i[77],i.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(r.push(Et(),Nt()),await ya('scheduled_notifications')&&r.push(da(a)));let d=!1;const u=()=>{if(Y.IS_CAR&&n&&Pe('recipes.edit'))return!0;const e=ce.useOwner.getState().staff.find(e=>e.id===Ee.getState().staffRef);return!!e&&e.active&&Pe('recipes.edit')&&(0,h.costsAllowedFor)(e)};n&&u()&&await ya('ingredient_prices')&&(r.push((0,y.gpSyncSpec)('ing',u)),Ga.add('ingredient_prices'),await ya('card_costs')&&(r.push((0,y.gpSyncSpec)('card',u)),Ga.add('card_costs')),await ya('kitchen_deliveries')&&(r.push((0,y.gpSyncSpec)('del',u)),Ga.add('kitchen_deliveries')),await ya('kitchen_stock_counts')&&(r.push((0,y.gpSyncSpec)('count',u)),Ga.add('kitchen_stock_counts'))),(0,Ue.specialsSyncOn)()&&'guest'!==s&&await ya('specials_boards')&&(r.push((0,Ue.specialsBoardSpec)(a,()=>Pe('recipes.edit')||Pe('floor.manage')||Pe('*'))),Ga.add('specials_boards'));const c={onActivity:()=>Ne({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ne({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ne({lastError:`${t}: held back, ${s}`}),d||(d=!0,(async()=>{try{if(!(await Ba('whoami')??[]).some(t=>t.venue_id===e))return void(Qa===a&&Ha());for(const a of je){if(a.spec.name!==t)continue;const{count:s,error:n}=await Te().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{d=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||W.useBookingSaves.getState().mark({id:t,table:e,why:ls()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||Q.useTempSaves.getState().mark({id:t,table:e,why:ws(e)??'this screen could not send it'})}};je=r.map(t=>new Z.EntityBridge(t,e,c)),await Promise.all(je.map(e=>e.start()));let l=0;const f=async()=>{if(!(l&&Date.now()-l<6e4)){l=Date.now();try{await p()}finally{l=0}}},p=async()=>{if(n&&(0,M.isOnline)())try{const t=await Ba('whoami');if(!t?.some(t=>t.venue_id===e))return void(Qa===a&&Ha())}catch(e){if(Na(e)){if(Y.IS_CAR)return void(Qa===a&&Ha());const e=await Ea();return void('ok'!==e&&'refused'!==e||Qa===a&&Ha())}}let t=0;for(const[a,s]of je.entries()){const n='chat'===r[a]?.name;try{await s.read(),t++,n&&(ke.useChatSync.getState().error&&ke.useChatSync.setState({error:void 0}),await Jt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&ke.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({mode:'live',lastSyncAt:e,lastServerAt:e}),H.mutationQueue.flush()}else Ne({mode:'offline'});if(!Pe('wages.view')){const e=Ee.getState().staffRef;ce.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([f(),new Promise(e=>setTimeout(e,3e4))]);const g=new Map;for(const e of je)g.set(e.spec.table,[...g.get(e.spec.table)??[],e]);const m=[...g.keys()].filter(e=>Ga.has(e)).map(e=>({table:e,venueColumn:g.get(e)[0].spec.venueColumn}));let _=!1;const S=(0,Z.venueChannel)(e,m,(e,t,a)=>{for(const s of g.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ne({lastSyncAt:s,lastServerAt:s})},e=>{Ne({realtime:e}),'SUBSCRIBED'===e?(_&&f(),_=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(_=!0)});Le.push(()=>{Te().removeChannel(S)}),Le.push((0,M.onConnectivity)(e=>{e&&f()}));const w=je.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),v=(0,x.superviseSync)({fastMs:za(Me),readFast:async()=>{for(const e of w)await e.read()},readAll:f,flush:()=>{H.mutationQueue.flush()},wake:()=>{H.mutationQueue.retryNow()},restart:()=>{Qa===a&&Ha()},realtime:()=>Ee.getState().realtime,lastServerAt:()=>{const e=Ee.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,M.setOnline)(!0),Ne({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Na,refreshAuth:async()=>{await Te().auth.refreshSession()},heartbeat:()=>Za(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Le.push(v.stop)}async function Za(e){const t=Ee.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ba('sync_heartbeat',{p_venue:e,p_device:(0,D.deviceId)()??'unknown',p_app:Me,p_version:j.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const za=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ee.getState(),queue:H.mutationQueue.pending.map(e=>e.table),failedTables:H.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),ye.PITCH&&(window.__ccSyncPreview=e=>Ne(e)));const Ya='guest:sent:v1';async function Xa(e){Ne({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ba('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!ee.IS_ISOLATED_VENUE||t.id===ee.VENUE_UUID)){Ne({venueId:t.id,venueName:t.name}),await Os(e);const a=t.app?.restaurant;a&&z.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withVenueAddress)({...a,id:e}):t)})),jt(e,t.app?.events)}await es(e),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ne({mode:(0,M.isOnline)()?'local':'offline'})}const t=setInterval(()=>{es(e).catch(()=>{})},6e4);Le.push(()=>clearInterval(t)),ee.IS_ISOLATED_VENUE||await ts(e)}async function es(e){const t=await Ba('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));ne.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);return s?{...(0,d.applyServerCard)(t,s),photo:s.photo_url||void 0}:t.signOff?{...t,signOff:null}:t})}))}const a=t.map(t=>(0,d.serverItem)(t,e)).filter(e=>!!e);a.length&&z.useStore.setState(e=>{const t=new Map(a.map(e=>[e.id,e])),s=e.menu.map(e=>t.get(e.id)??e),n=new Set(s.map(e=>e.id));return{menu:[...s,...a.filter(e=>!n.has(e.id))]}});try{const t=await Ba('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function ts(e){let t=await L.kv.get(Ya,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=z.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),r=a.orders.filter(a=>a.restaurantId===e&&(0,le.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||r.length){if(!await La())return;for(const a of n)try{const s=(await Ba('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];t={...t,[a.id]:'booking'};const n={};s?.status&&s.status!==a.status&&(n.status=s.status),'string'==typeof s?.ref&&s.ref&&s.ref!==a.ref&&(n.ref=s.ref),Object.keys(n).length&&z.useStore.setState(e=>({bookings:e.bookings.map(e=>e.id===a.id?{...e,...n}:e)}))}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ne({lastError:`Booking: ${e?.message}`}))}for(const a of r)try{const s=(await Ba('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...Qe(a),...(0,R.takeGuard)(a.id),allergies:We(a.allergies)}}))?.[0];if(t={...t,[a.id]:'order'},s&&z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?ss(e,s):e)})),'boolean'==typeof a.marketingOptIn&&a.email)try{await Ba('guest_marketing_consent',{p_order:a.id,p_opt_in:a.marketingOptIn})}catch{}}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ne({lastError:`Order: ${s}`}),z.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:ns(s)}}:e)})))}await L.kv.set(Ya,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ba('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await L.kv.set(Ya,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ba('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));z.useStore.setState(e=>({bookings:e.bookings.map(e=>{const a=t.get(e.id);return a&&a.status&&a.status!==e.status&&'declined'!==a.status?{...e,status:a.status}:'declined'===a?.status&&'cancelled'!==e.status?{...e,status:'cancelled'}:e}),orders:e.orders.map(e=>{const a=t.get(e.id);if(!a)return e;const s=ss(e,a);return as(s)===as(e)?e:s})})),Ne({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ne({mode:(0,M.isOnline)()?Ee.getState().mode:'offline'})}finally{a=!1}}};Le.push(z.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),$a=setInterval(()=>{n()},15e3),rs=()=>{n()},n()}const as=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function ss(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const ns=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let rs=null;const is={bridges:()=>je,restart:Ha};function os(){const e=Ee.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Pe('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function ds(){const e=je.find(e=>'stock_events'===e.spec.table);if(!e||os())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(H.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function us(){const e=je.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}ds();try{await H.mutationQueue.retryNow()}catch{}}Ee.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{us()},3e3)});const cs=['bookings','walk_ins'];function ls(){const e=Ee.getState();return Ke()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const fs=()=>je.filter(e=>cs.includes(e.spec.table)),ps=e=>H.mutationQueue.failed.some(t=>cs.includes(t.table)&&t.rowKey===e);function gs(e=!1){return ls()?0:fs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ps(t)&&!!W.useBookingSaves.getState().notSaved[t]),0)}async function ms(e=!1){const t=ls();if(t)return t;for(const e of fs())try{await e.read()}catch{}gs(e);try{await H.mutationQueue.retryNow()}catch{}return e&&_s(),null}function _s(){const e=fs()[0]?.venueId??'',t=W.useBookingSaves.getState(),a=new Set(fs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ps(s)||cs.some(t=>H.mutationQueue.hasPending(t,e,s))||t.clear(s)}H.mutationQueue.onFailed(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{cs.includes(e.table)&&W.useBookingSaves.getState().clear(e.rowKey)});let ys=null;const hs=(e=2500)=>{ys&&clearTimeout(ys),ys=setTimeout(()=>{ys=null,ms(!1)},e)};(0,M.onConnectivity)(e=>{e&&hs()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3e3)});const Ss=['temp_readings','temp_units'];function ws(e="temp_readings"){const t=Ee.getState();return Ke()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||st()?'device'!==t.kind||Pe('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const vs=()=>je.filter(e=>Ss.includes(e.spec.table));async function ks(e=!1){const t=ws();if(t)return t;for(const e of vs())try{await e.read()}catch{}const a=vs()[0]?.venueId??'';for(const t of vs())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,H.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await H.mutationQueue.retryNow()}catch{}if(e){const e=Q.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=vs().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||H.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,Q.tempKey)(t.table,t.id))}}return null}H.mutationQueue.onFailed(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,$.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),H.mutationQueue.onDone(e=>{Ss.includes(e.table)&&Q.useTempSaves.getState().clear((0,Q.tempKey)(e.table,e.rowKey))});let bs=null;const Is=(e=3e3)=>{bs&&clearTimeout(bs),bs=setTimeout(()=>{bs=null,ks(!1)},e)};(0,M.onConnectivity)(e=>{e&&Is()}),Ee.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Pe('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&Is(3500)});const Rs='golive:v1:';async function Os(e){'live'!==z.useStore.getState().clock.mode&&z.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)?await Ts(e):(await L.kv.get(Rs+e,!1)||await Ts(e),await L.kv.get(Ds+e,!1)||(Us(e),await L.kv.set(Ds+e,!0)),await L.kv.get(As+e,!1)||(Cs(),await L.kv.set(As+e,!0)))}const As='golive:v3:';function Cs(){const e=e=>JSON.stringify(e).includes('(example)');try{de.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const Ds='golive:v2:';function Us(e){const t=e=>JSON.stringify(e).includes('(example)');z.useStore.setState(t=>({customer:{...t.customer,name:'',email:'',phone:'',allergies:[],allergyConsent:!1,marketingOptIn:{}},stampCards:t.stampCards.filter(t=>t.restaurantId!==e),giftCards:t.giftCards.filter(t=>t.restaurantId!==e),ratings:t.ratings.filter(t=>t.restaurantId!==e),events:t.events.filter(t=>!(t.example&&(t.restaurantId===e||null===t.restaurantId)))})),ce.useOwner.setState(e=>({referrals:[],coats:[],merchOrders:[],lost:[],customerTags:{},offers:e.offers.filter(e=>!t(e)),changeRequests:e.changeRequests.filter(e=>!t(e)),campaigns:e.campaigns.filter(e=>!t(e)),supplierOrders:e.supplierOrders.filter(e=>!t(e)),chat:e.chat.filter(e=>e.id.startsWith('m-seed-')).map((e,t)=>({...e,at:new Date(Date.now()-6e4*(5-t)).toISOString()}))}))}async function Ts(e){if(g.LIVE_VENUE_BUILD&&(0,g.isLiveVenue)(e)){const t=(0,m.stripCoreLiveSamples)(z.useStore.getState()),a=(0,de.stripKitchenExamples)(de.useKitchen.getState()),s=ce.useOwner.getState(),n=(0,m.stripOwnerLiveSamples)(s),r={accidents:ue.useSafety.getState().accidents.filter(e=>!(0,ue.isSeedAccident)(e))},i=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));i(z.useStore.getState(),t)&&(await(0,_.archiveChefCache)('core',z.useStore.getState()),z.useStore.setState(t)),i(de.useKitchen.getState(),a)&&(await(0,_.archiveChefCache)('kitchen',de.useKitchen.getState()),de.useKitchen.setState(a)),i(s,n)&&(await(0,_.archiveChefCache)('owner',s),ce.useOwner.setState(n)),i(ue.useSafety.getState(),r)&&(await(0,_.archiveChefCache)('safety',ue.useSafety.getState()),ue.useSafety.setState(r));const o=(0,U.stripHrSamples)(U.useHr.getState());i(U.useHr.getState(),o)&&(await(0,_.archiveChefCache)('hr',U.useHr.getState()),U.useHr.setState(o));const d=(0,y.stripGpSamples)(y.useGpCalc.getState());i(y.useGpCalc.getState(),d)&&(await(0,_.archiveChefCache)('gp',y.useGpCalc.getState()),y.useGpCalc.setState(d));const u=re.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};i(u,c)&&(await(0,_.archiveChefCache)('order-sheets',u),re.useOrderSheets.setState(c));const l=ne.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,g.isLiveVenue)(e.restaurantId)||!(0,w.isDemoCard)(e)),log:l.log.filter(e=>!(0,w.demoActor)(e.by))};return i(l,f)&&(await(0,_.archiveChefCache)('recipe-cards',l),ne.useCardStore.setState(f)),void await L.kv.set(Rs+e,!0)}const t=t=>t.restaurantId===e&&!(0,le.isUuid)(t.id);z.useStore.setState(a=>({bookings:a.bookings.filter(e=>!t(e)),orders:a.orders.filter(e=>!t(e)),waitlist:a.waitlist.filter(t=>t.restaurantId!==e),walkIns:Object.fromEntries(Object.entries(a.walkIns).filter(([t])=>!t.includes(e)))})),te.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,le.isUuid)(t.id))})),ae.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ce.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,le.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,le.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,le.isUuid)(e.id)),leave:e.leave.filter(e=>(0,le.isUuid)(e.id)),swaps:[]}));try{de.useKitchen.setState(e=>(0,de.stripKitchenExamples)(e))}catch{}ce.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,le.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,le.isUuid)(e.id)&&(0,le.isUuid)(e.supplierId))}));try{ue.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await L.kv.set(Rs+e,!0)}const Es=(e,t)=>Qe({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function Ns(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(ae.useFloor.getState().live[e]??{}).map(([e,t])=>Es(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ee.getState().kind||Pe('device.write'),deletes:!1,matchKey:e=>({table_name:e}),toRow:(e,t)=>({venue_id:t,table_name:e.name,stage:e.stage??null,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note?e.note.slice(0,200):null,updated_by:(0,X.actorStamp)({isCar:Y.IS_CAR,kind:Ee.getState().kind,staffRef:Ee.getState().staffRef,fallback:Me})}),fromRow:e=>Es(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>ae.useFloor.setState(s=>{const n={...s.live[e]??{}};for(const e of t){const{name:t,...a}=e;n[t]=a}for(const e of a)delete n[e];return{live:{...s.live,[e]:n}}}),subscribe:e=>ae.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Ps(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(oe.useSetup.getState().sites[e]?.grades??oe.DEFAULT_GRADES).map((e,t)=>({id:e.id,name:e.name,pence:e.pence,sort:t})),key:e=>e.id,rowKey:e=>String(e.grade_id),syncable:e=>!!e.id&&!!e.name,writable:()=>Pe('wages.manage'),matchKey:e=>({grade_id:e}),toRow:(e,t)=>({venue_id:t,grade_id:e.id,name:e.name.slice(0,60),pence:Math.max(0,Math.min(1e5,Math.round(e.pence))),sort:e.sort}),fromRow:e=>({id:String(e.grade_id),name:String(e.name),pence:Number(e.pence),sort:Number(e.sort??0)}),apply:(t,a)=>{if(!t.length&&!a.length)return;const s=oe.useSetup.getState().sites[e]?.grades??[],n=new Map(s.map((e,t)=>[e.id,{...e,sort:t}]));for(const e of t)n.set(e.id,e);for(const e of a)n.delete(e);const r=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));oe.useSetup.getState().patch(e,{grades:r})},subscribe:t=>oe.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ks='staff-avatars',Ms=new Map;let xs=!1;const qs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function js(){if(!xs){xs=!0;try{for(const[e,t]of Ms){const a=ie.useAvatars.getState().photos[e];if(!t){a?.path&&ie.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ee.getState().staffRef)continue;const{data:s,error:n}=await Te().storage.from(Ks).download(t);if(n||!s)continue;const r=await qs(s);r.startsWith('data:image/')&&ie.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:r,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{xs=!1}}}function Ls(e){const t=async()=>{const t=Ee.getState().staffRef,a=t?ht.get(t)??Ee.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ee.getState().kind)return;const s=ie.useAvatars.getState().photos[t];try{const n=Ms.get(t),r=t=>{t&&t.startsWith(`${e}/${a}-`)&&Te().storage.from(Ks).remove([t]).catch(()=>{})};if(!s){const e=!!ie.useAvatars.getState().clears?.[t];return e&&n&&(await Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}),Ms.set(t,null),r(n)),void(e&&ie.useAvatars.getState().doneClear(t))}if(s.path)return;const i=await(await fetch(s.dataUrl)).blob();if(i.size>512e3)return void Ne({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===i.type?'jpg':'image/webp'===i.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Te().storage.from(Ks).upload(d,i,{upsert:!1,contentType:i.type||'image/png'});if(u)throw u;await Ba('set_staff_avatar',{p_staff_ref:t,p_path:d}),Ms.set(t,d),n!==d&&r(n),ie.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ne({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ie.useAvatars.getState().photos},s=ie.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Pe('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ee.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Ms.set(t,null),ie.useAvatars.getState().doneClear(t),Ba('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Te().storage.from(Ks).remove([e])).catch(()=>{})}});return t(),s}const Bs=new Map,$s=(0,N.create)(()=>({n:0}))},946,[947,948,949,891,806,817,950,822,818,823,951,955,956,820,958,960,961,962,963,964,839,965,966,969,972,973,831,892,935,974,975,976,979,936,980,978,983,977,984,985,986,988,991,987,816,856,992,805,993,996,942,868,998,885,886,1000,1001,876,854,1003,1006,1008,1009,1010,880,1011,1012,1013,1014,1015,1016,938,940,869,847,842,1017,1020,1021]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},947,[831]); __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"UK14",{enumerable:!0,get:function(){return t}}),e.cardAllergenMap=n,e.applyServerCard=function(t,s){const i=s.updated_at?new Date(String(s.updated_at)).toISOString():t.updatedAt,o=s.doc?.item?.allergenNotes;return{...t,allergens:n(s.allergens,s.may_contain),allergenNotes:'string'==typeof o&&o?o:void 0,dish:'string'==typeof s.dish&&s.dish?s.dish:t.dish,section:'string'==typeof s.section&&s.section?s.section:t.section,price:'number'==typeof s.price_pence?s.price_pence:t.price,signOff:t.signOff??{by:'Head chef',at:i}}},e.serverItem=function(t,s){const i=t.doc?.item;return i&&i.id?{...i,restaurantId:s,allergens:n(t.allergens,t.may_contain)}:null},Object.defineProperty(e,"noAllergenWords",{enumerable:!0,get:function(){return s}});const t=['gluten','crustaceans','molluscs','eggs','fish','peanuts','treenuts','soya','milk','celery','mustard','sesame','sulphites','lupin'];function n(n,s){const i=n=>Array.isArray(n)?n.map(String).filter(n=>t.includes(n)):[],o={};for(const t of i(s))o[t]='may';for(const t of i(n))o[t]='contains';return o}const s=t=>t?'No listed allergens':'Allergens not confirmed yet: ask staff'},948,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.start{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},976,[17,977]); __d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MutationQueue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();constructor(){(0,t.onConnectivity)(t=>{t&&this.flush()})}setExecutor(t){this.exec=t}load(){return this.loaded||(this.loaded=(async()=>{const t=await e.kv.get(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}get failed(){return this.failedItems}hasPending(t,e,s){return this.items.some(n=>n.table===t&&n.venueId===e&&n.rowKey===s)}async enqueue(t){await this.load();const s={...t,id:(0,e.uuid)(),createdAt:(new Date).toISOString(),attempts:0};return this.items.push(s),await this.persist(),this.flush(),s}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}scheduleRetry(){if(this.retryTimer)return;const e=this.backoffMs;this.backoffMs=Math.min(2*this.backoffMs,6e4),this.retryTimer=setTimeout(()=>{this.retryTimer=null,(0,t.setOnline)(!0),this.flush()},e)}async persist(){await e.kv.set(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},977,[974,936,978]); __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},978,[974]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.196'},979,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"APP_VERSION",{enumerable:!0,get:function(){return t}});const t='v0.3.12.197'},979,[]); __d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{constructor(t,s={}){this.table=t,this.opts=s,this.keyOf=s.keyOf??(t=>String(t.id)),this.keyColumns=s.keyColumns??['id'],this.venueCol=s.venueColumn??'venue_id'}rows(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'delete',rowKey:n,match:u})}matchFor(t,s){if(1===this.keyColumns.length&&'id'===this.keyColumns[0])return{id:t};const n={};for(const t of this.keyColumns)n[t]=s?.[t];return n}}},980,[981,982,892,936,977]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`cache:${t}:${n}`;function f(t){let s=n.get(t);return s||(s=new Map,n.set(t,s)),s}function p(n){s.delete(n),c.get(n)?.forEach(t=>t());const u=o.get(n);u&&clearTimeout(u),o.set(n,setTimeout(()=>{o.delete(n),t.kv.set(n,Array.from(f(n).entries()))},250))}const w={async hydrate(n,s){const c=l(n,s);if(u.has(c))return;u.add(c);const o=await t.kv.get(c,[]),w=f(c);let h=0;for(const[t,n]of o)w.has(t)||(w.set(t,n),h++);h&&p(c)},rows(t,n){const c=l(t,n);let o=s.get(c);return o||(o=Array.from(f(c).values()),s.set(c,o)),o},get:(t,n,s)=>f(l(t,n)).get(s),put(t,n,s,c){f(l(t,n)).set(s,c),p(l(t,n))},patch(t,n,s,c){const o=f(l(t,n)),u=o.get(s);u&&(o.set(s,{...u,...c}),p(l(t,n)))},remove(t,n,s){f(l(t,n)).delete(s)&&p(l(t,n))},replace(t,s,c,o=()=>!1){const u=l(t,s),w=f(u),h=new Map(c);w.forEach((t,n)=>{o(n)&&h.set(n,t)}),n.set(u,h),p(u)},subscribe(t,n,s){const o=l(t,n);let u=c.get(o);return u||(u=new Set,c.set(o,u)),u.add(s),()=>{u?.delete(s)}},async clearVenue(o,f){for(const p of f){const f=l(p,o);n.delete(f),s.delete(f),u.delete(f),await t.kv.remove(f),c.get(f)?.forEach(t=>t())}}}},982,[936]); diff --git a/staff-app/admin.html b/staff-app/admin.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/admin.html +++ b/staff-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer.html b/staff-app/customer.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer.html +++ b/staff-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage.html b/staff-app/customer/anchorage.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage.html +++ b/staff-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/book.html b/staff-app/customer/anchorage/book.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/book.html +++ b/staff-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/feedback.html b/staff-app/customer/anchorage/feedback.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/feedback.html +++ b/staff-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/gift.html b/staff-app/customer/anchorage/gift.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/gift.html +++ b/staff-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/lost.html b/staff-app/customer/anchorage/lost.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/lost.html +++ b/staff-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/loyalty.html b/staff-app/customer/anchorage/loyalty.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/loyalty.html +++ b/staff-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/merch.html b/staff-app/customer/anchorage/merch.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/merch.html +++ b/staff-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/offers.html b/staff-app/customer/anchorage/offers.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/offers.html +++ b/staff-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/refer.html b/staff-app/customer/anchorage/refer.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/refer.html +++ b/staff-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/waitlist.html b/staff-app/customer/anchorage/waitlist.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/waitlist.html +++ b/staff-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/whatson.html b/staff-app/customer/anchorage/whatson.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/anchorage/whatson.html +++ b/staff-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/basket.html b/staff-app/customer/basket.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/basket.html +++ b/staff-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/profile.html b/staff-app/customer/profile.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/customer/profile.html +++ b/staff-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/demo.html b/staff-app/demo.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/demo.html +++ b/staff-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/display.html b/staff-app/display.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/display.html +++ b/staff-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/index.html b/staff-app/index.html index 16a5019038228d32cc46ea6e3a1b88bf95cd468e..e9777f3e79e2d4aecb3eef8aaa449746da3ebace 100644 --- a/staff-app/index.html +++ b/staff-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/kitchen.html b/staff-app/kitchen.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/kitchen.html +++ b/staff-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/owner.html b/staff-app/owner.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/owner.html +++ b/staff-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/staff.html b/staff-app/staff.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/staff.html +++ b/staff-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/sw.js b/staff-app/sw.js index 323df61cb33506ef4d3363dd5cbced7ecf5ee327..f8231606f45c00c21914a3fad590049bf9f94e86 100644 --- a/staff-app/sw.js +++ b/staff-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Staff service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-staff-bf82df876b"; +const V = "cc-staff-b2805dd22c"; const BASE = "/staff-app/"; -const PRECACHE = ["/staff-app/apple-touch-icon.png", "/staff-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/staff-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/staff-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/staff-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/staff-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/staff-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/staff-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/staff-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/staff-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/staff-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/staff-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/staff-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/staff-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/staff-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/staff-app/brand-logo.png", "/staff-app/favicon.ico", "/staff-app/icon-192.png", "/staff-app/icon-512.png", "/staff-app/icon-maskable-192.png", "/staff-app/icon-maskable-512.png", "/staff-app/manifest.webmanifest", "/staff-app/index.html", "/staff-app/_expo/static/js/web/bundle.js?v=bf82df876bdc854e95d6562e6b5c06b93a3daaec0785d3cfe9a6e7ed9e9ae511"]; +const PRECACHE = ["/staff-app/apple-touch-icon.png", "/staff-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/staff-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/staff-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/staff-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/staff-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/staff-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/staff-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/staff-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/staff-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/staff-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/staff-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/staff-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/staff-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/staff-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/staff-app/brand-logo.png", "/staff-app/favicon.ico", "/staff-app/icon-192.png", "/staff-app/icon-512.png", "/staff-app/icon-maskable-192.png", "/staff-app/icon-maskable-512.png", "/staff-app/manifest.webmanifest", "/staff-app/index.html", "/staff-app/_expo/static/js/web/bundle.js?v=b2805dd22c2be096900b793a1ecc0994d16cd9c9af040191737db16264754ad6"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/staff-app/team.html b/staff-app/team.html index 6aa101920c3b4e8caad6ba3e026ed1799026d07d..6f67a1d09f24f8f70a083a6e22198fa7ab9c344c 100644 --- a/staff-app/team.html +++ b/staff-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - +